-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
48 lines (40 loc) · 919 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
36
37
38
39
40
41
42
43
44
45
46
47
48
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username TEXT,
password TEXT
);
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name TEXT
);
CREATE TABLE recipes (
id SERIAL PRIMARY KEY,
name TEXT,
instructions TEXT,
user_id INTEGER REFERENCES users
);
CREATE TABLE ingredients (
id SERIAL PRIMARY KEY,
recipes_id INTEGER REFERENCES recipes ON DELETE CASCADE,
product_id INTEGER REFERENCES products,
amount FLOAT,
unit TEXT
);
CREATE TABLE basket (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users,
product_id INTEGER REFERENCES products,
amount FLOAT,
unit TEXT
);
CREATE TABLE shopping_list (
lists_id INTEGER REFERENCES lists ON DELETE CASCADE,
product_id INTEGER REFERENCES products,
amount FLOAT,
unit TEXT
);
CREATE TABLE lists (
id SERIAL PRIMARY KEY,
name TEXT,
user_id INTEGER REFERENCES users
);