-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtables.sql
More file actions
36 lines (33 loc) · 901 Bytes
/
tables.sql
File metadata and controls
36 lines (33 loc) · 901 Bytes
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
CREATE TABLE Items (
item_id INTEGER PRIMARY KEY AUTOINCREMENT,
quantity INTEGER,
price REAL,
item_name TEXT,
category TEXT,
description TEXT
);
CREATE TABLE Accounts (
user_name TEXT PRIMARY KEY NOT NULL,
user_password TEXT NOT NULL,
email TEXT NOT NULL,
balance REAL DEFAULT 2500 NOT NULL
);
CREATE TABLE Feedbacks (
feedback_id INTEGER PRIMARY KEY AUTOINCREMENT,
item_id INTEGER,
user_name TEXT,
score INTEGER,
feedback_text TEXT,
FOREIGN KEY (item_id) REFERENCES Items(item_id),
FOREIGN KEY (user_name) REFERENCES Accounts(user_name)
);
CREATE TABLE Transactions (
transaction_id INTEGER PRIMARY KEY AUTOINCREMENT,
user_name TEXT,
item_id INTEGER,
total_price REAL,
quantity INTEGER,
transaction_date DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_name) REFERENCES Accounts(user_name),
FOREIGN KEY (item_id) REFERENCES Items(item_id)
);