Last active
February 4, 2021 09:20
-
-
Save rtt/5de1eaea3a779aaa0c67af119dcd1b93 to your computer and use it in GitHub Desktop.
foo bar baz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- table a: | |
create table a ( | |
uid text primary key, | |
title text not null | |
); | |
create table u ( | |
uid text primary key, | |
name text not null, | |
email text not null --unique | |
); | |
create table b ( | |
uid text primary key, | |
a_uid text references a(uid), | |
u_uid text references u(uid), | |
amount integer not null | |
); | |
-- make As | |
insert into a (uid, title) values ('a_1', 'a'); | |
insert into a (uid, title) values ('a_2', 'a'); | |
-- make Us | |
insert into u (uid, name, email) values ('u_1', 'darren'); | |
insert into u (uid, name, email) values ('u_2', 'kim'); | |
-- make Bs | |
insert into b (uid, a_uid, u_uid, amount) values ('a_1', 'u_1', 100); | |
insert into b (uid, a_uid, u_uid, amount) values ('a_1', 'u_2', 150); | |
insert into b (uid, a_uid, u_uid, amount) values ('a_1', 'u_1', 200); | |
insert into b (uid, a_uid, u_uid, amount) values ('a_2', 'u_1', 100); | |
insert into b (uid, a_uid, u_uid, amount) values ('a_2', 'u_2', 150); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment