-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
35 lines (32 loc) · 812 Bytes
/
schema.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
CREATE TABLE users
(
id SERIAL4 PRIMARY KEY,
name VARCHAR(300) NOT NULL,
email VARCHAR(300) NOT NULL UNIQUE,
password_digest VARCHAR(400) NOT NULL
);
CREATE TABLE storage_types
(
id SERIAL4 PRIMARY KEY,
storage_name VARCHAR(200) NOT NULL
);
CREATE TABLE food_items
(
id SERIAL4 PRIMARY KEY,
item_name VARCHAR(200) NOT NULL,
purchase_date DATE NOT NULL,
expiry_date DATE NOT NULL,
status VARCHAR(100) NOT NULL,
notification DATE NOT NULL,
user_id INTEGER NOT NULL,
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE RESTRICT,
storage_type_id INTEGER NOT NULL,
FOREIGN KEY (storage_type_id) REFERENCES storage_types (id) ON DELETE RESTRICT
);
CREATE TABLE food_guide
(
id SERIAL4 PRIMARY KEY,
food_name VARCHAR(200),
use_by_time VARCHAR(100),
icon_url VARCHAR(400)
);