-
Notifications
You must be signed in to change notification settings - Fork 0
/
tables.sql
71 lines (64 loc) · 1.54 KB
/
tables.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
CREATE TABLE IF NOT EXISTS favourites (
id SERIAL PRIMARY KEY,
shop_id INTEGER,
user_id INTEGER,
seller_id INTEGER
);
CREATE TABLE IF NOT EXISTS sellers (
id SERIAL PRIMARY KEY,
username TEXT NOT NULL,
hashed_password TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username TEXT NOT NULL,
hashed_password TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS shops (
id SERIAL PRIMARY KEY,
shop_name TEXT NOT NUll,
image_url TEXT,
about TEXT,
category_id INTEGER,
seller_id INTEGER REFERENCES sellers(id),
favourites_count INTEGER DEFAULT 0
);
CREATE TABLE IF NOT EXISTS categories (
id SERIAL PRIMARY KEY,
category_name TEXT
);
CREATE TABLE IF NOT EXISTS listings (
id SERIAL PRIMARY KEY,
listing_name TEXT,
listing_details TEXT,
image_url TEXT,
quantity INTEGER,
price NUMERIC (6,2),
shop_id INTEGER,
category_id INTEGER,
created_at TIMESTAMP DEFAULT now()
);
CREATE TABLE IF NOT EXISTS reviews (
id SERIAL PRIMARY KEY,
review TEXT,
rating NUMERIC (3,2),
shop_id INTEGER,
user_id INTEGER,
created_at TIMESTAMP DEFAULT now()
);
CREATE TABLE IF NOT EXISTS enquiries (
id SERIAL PRIMARY KEY,
item_name TEXT,
enquirer_id INTEGER,
enquirer_name TEXT,
email_address TEXT NOT NULL,
query TEXT,
shop_id INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS responses (
id SERIAL PRIMARY KEY,
enquirer_id INTEGER,
respondent_id INTEGER,
enquiry_id INTEGER,
response TEXT
);