-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_tables.sql
More file actions
38 lines (38 loc) · 1.07 KB
/
create_tables.sql
File metadata and controls
38 lines (38 loc) · 1.07 KB
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 user (
id INTEGER NOT NULL,
username VARCHAR(20) NOT NULL,
password VARCHAR(80) NOT NULL,
fullname VARCHAR(50) NOT NULL,
created_at DATETIME,
active BOOLEAN,
PRIMARY KEY (id)
);
CREATE TABLE user_session (
id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
session VARCHAR(50) NOT NULL,
created_at DATETIME,
valid BOOLEAN,
PRIMARY KEY (id),
FOREIGN KEY(user_id) REFERENCES user (id)
);
CREATE TABLE category (
id INTEGER NOT NULL,
name VARCHAR(20) NOT NULL,
description VARCHAR(50) NOT NULL,
"order" INTEGER,
created_at DATETIME,
deleted BOOLEAN,
PRIMARY KEY (id)
);
CREATE TABLE product (
id INTEGER NOT NULL,
name VARCHAR(20) NOT NULL,
description VARCHAR(50) NOT NULL,
"order" INTEGER,
price INTEGER,
category_id INTEGER NOT NULL,
deleted BOOLEAN,
PRIMARY KEY (id),
FOREIGN KEY(category_id) REFERENCES category (id)
);