-
Notifications
You must be signed in to change notification settings - Fork 0
/
tableCreation.sql
49 lines (45 loc) · 1.21 KB
/
tableCreation.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
CREATE TABLE Appointment (
date DATE NOT NULL,
customer_id INTEGER NOT NULL,
car_id INTEGER NOT NULL,
FOREIGN KEY (customer_id) REFERENCES Customer(customer_id),
FOREIGN KEY (car_id) REFERENCES Car(car_id),
PRIMARY KEY("car_id","date")
)
CREATE TABLE "Car" (
"car_id" INTEGER,
"make" TEXT NOT NULL,
"model" TEXT NOT NULL,
"year" INTEGER NOT NULL,
"price" REAL NOT NULL,
"mileage" INTEGER NOT NULL,
"reportUrl" TEXT NOT NULL,
"location" TEXT NOT NULL,
"seller_id" INTEGER NOT NULL,
PRIMARY KEY("car_id"),
FOREIGN KEY("seller_id") REFERENCES "Seller"("seller_id")
)
CREATE TABLE "Customer" (
"customer_id" INTEGER,
"username" TEXT NOT NULL UNIQUE,
"password" TEXT NOT NULL,
"email" TEXT NOT NULL,
"phone" INTEGER NOT NULL,
PRIMARY KEY("customer_id")
)
CREATE TABLE Mark (
customer_id INTEGER NOT NULL,
car_id INTEGER NOT NULL,
FOREIGN KEY (customer_id) REFERENCES Customer(customer_id),
FOREIGN KEY (car_id) REFERENCES Car(car_id),
PRIMARY KEY("customer_id","car_id")
)
CREATE TABLE "Seller" (
"seller_id" INTEGER,
"username" TEXT NOT NULL UNIQUE,
"password" TEXT NOT NULL,
"email" TEXT NOT NULL,
"phone" TEXT NOT NULL,
"ssn" INTEGER NOT NULL,
PRIMARY KEY("seller_id")
)