-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheme.sql
32 lines (28 loc) · 1 KB
/
scheme.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
create table plus_user(
user_id int primary key generated always as identity,
username varchar(256) not null,
-- can update to password and use passhash instead or chkpass extension
password_ varchar(256) not null,
display_name varchar(256)
);
create table post(
post_id int primary key generated always as identity,
user_id int not null,
date_posted int not null,
content varchar(5000) not null
);
create table like_(
user_id int not null,
post_id int not null
)
create table comment(
user_id int not null,
post_id int not null,
comment varchar(3000) not null
)
alter table post add foreign key (user_id) references user_(user_id);
alter table like_ add foreign key (user_id) references user_(user_id);
alter table comment add foreign key (user_id) references user_(user_id);
alter table like_ add foreign key (post_id) references post(post_id);
alter table comment add foreign key (post_id) references post(post_id);
alter table user_ add constraint username unique;