Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table users(id int primary key, name varchar);
- create table groups(id int primary key, name varchar);
- create table user_groups(uid int references users(id), gid int references groups(id);
- insert into users values (1, 'John'), (2, 'Bob'), (3, 'Maria'), (4, 'Jin');
- insert into groups values (1, 'Persons - A'), (2, 'Persons - B'),
- (3, 'Persons - C'), (4, 'Persons - D'), (5, 'Pay - A'), (6, 'Pay - B'), (7, 'Pay - C');
- insert into user_groups values (1, 1), (1, 2), (2, 1), (2, 4), (2, 6), (2, 7),
- (3, 5), (3, 7), (4, 1), (4, 3);
- id name groups_user_has_access_to
- 2 Bob Persons - A, Persons - D, Pay - B, Pay - C
- 3 Maria Pay - A, Pay - C
Add Comment
Please, Sign In to add comment