-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.sql
41 lines (38 loc) · 862 Bytes
/
create.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
drop table if exists User;
CREATE TABLE User (
UserId TEXT,
rating INTEGER,
Location TEXT,
Country TEXT,
PRIMARY KEY (UserId)
);
drop table if exists Item;
CREATE TABLE Item (
ItemId INTEGER,
name TEXT,
UserId TEXT,
Currently REAL,
First_Bid REAL,
Number_of_Bids INTEGER,
Started DATETIME,
End DATETIME,
Description TEXT,
PRIMARY KEY (ItemId),
FOREIGN KEY (UserId) REFERENCES User (UserId)
);
drop table if exists Bid;
CREATE TABLE Bid (
ItemId INTEGER,
UserId TEXT,
BidTime DATETIME,
Amount REAL,
PRIMARY KEY (ItemId, UserId, BidTime),
FOREIGN KEY (ItemId) REFERENCES Item (ItemId) FOREIGN KEY (UserId) REFERENCES User (UserId)
);
drop table if exists Category;
CREATE TABLE Category(
ItemId INTEGER,
Category_Name TEXT,
PRIMARY KEY (ItemId, Category_Name),
FOREIGN KEY (ItemId) REFERENCES Item (ItemId)
);