-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitdb.sql
38 lines (34 loc) · 1.11 KB
/
initdb.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
33
34
35
36
37
38
create table usuario (
id int primary key identity(1,1),
username varchar(10) not null unique,
passwd char(69) not null
);
create table sesion (
token char(36) not null primary key,
userid int not null,
constraint fk_sesion_usuario foreign key (userid)
references usuario(id) on delete cascade on update cascade
);
create table category (
id int primary key identity(1,1),
name varchar(50) not null unique,
color varchar(50) not null
);
create table todo (
id int primary key identity(1,1),
task nvarchar(max) not null,
done bit default 0,
due_unix_timestamp bigint not null,
userid int not null,
constraint fk_todo_usuario foreign key (userid)
references usuario(id) on delete cascade on update cascade
);
create table category_todo (
categoryid int not null,
todoid int not null,
constraint fk_category_todo primary key (categoryid, todoid),
constraint fk_category_todo_category foreign key (categoryid)
references category(id) on delete cascade on update cascade,
constraint fk_category_todo_todo foreign key (todoid)
references todo(id) on delete cascade on update cascade
);