Guest User

Untitled

a guest
Jan 15th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. create table users(id int primary key, name varchar);
  2. create table groups(id int primary key, name varchar);
  3. create table user_groups(uid int references users(id), gid int references groups(id);
  4.  
  5. insert into users values (1, 'John'), (2, 'Bob'), (3, 'Maria'), (4, 'Jin');
  6.  
  7. insert into groups values (1, 'Persons - A'), (2, 'Persons - B'),
  8. (3, 'Persons - C'), (4, 'Persons - D'), (5, 'Pay - A'), (6, 'Pay - B'), (7, 'Pay - C');
  9.  
  10. insert into user_groups values (1, 1), (1, 2), (2, 1), (2, 4), (2, 6), (2, 7),
  11. (3, 5), (3, 7), (4, 1), (4, 3);
  12.  
  13. id name groups_user_has_access_to
  14. 2 Bob Persons - A, Persons - D, Pay - B, Pay - C
  15. 3 Maria Pay - A, Pay - C
Add Comment
Please, Sign In to add comment