Skip to content

Instantly share code, notes, and snippets.

@spiashko
Created October 27, 2020 18:13
Show Gist options
  • Save spiashko/bbdbd036a9bec3c3a5e302536ad301e7 to your computer and use it in GitHub Desktop.
Save spiashko/bbdbd036a9bec3c3a5e302536ad301e7 to your computer and use it in GitHub Desktop.
placeholder for name
drop table if exists users_groups;
drop table if exists users;
drop table if exists groups;
create table users
(
id int,
name varchar(50),
PRIMARY KEY (id)
);
create table groups
(
id int,
name varchar(50),
PRIMARY KEY (id)
);
create table users_groups
(
id int,
fk_user int,
fk_group int,
PRIMARY KEY (id),
foreign key (fk_user) references users (id),
foreign key (fk_group) references groups (id)
);
insert into users
values (1, 'ukek');
insert into users
values (2, 'ulol');
insert into groups
values (1, 'gkek');
insert into groups
values (2, 'glol');
insert into groups
values (3, 'gheh');
insert into users_groups
values (1, 1, 1);
insert into users_groups
values (2, 1, 2);
insert into users_groups
values (3, 1, 3);
insert into users_groups
values (4, 2, 1);
select *
from users;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment