-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex4_lab5.sql
More file actions
43 lines (41 loc) · 1.12 KB
/
Copy pathex4_lab5.sql
File metadata and controls
43 lines (41 loc) · 1.12 KB
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
create table SalesPerson(
sp_id INTEGER PRIMARY KEY
);
create table Customer(
customer_id INTEGER PRIMARY KEY
);
create table Mechanic(
mechanic_id INTEGER PRIMARY KEY
);
create table Car(
car_id INTEGER PRIMARY KEY,
customer_id INTEGER,
sp_id INTEGER,
foreign key(sp_id) REFERENCES SalesPerson(sp_id),
foreign key(customer_id) REFERENCES Customer(customer_id)
);
create table Invoice(
invoice_id INTEGER PRIMARY KEY,
car_id INTEGER,
invoiceDate date,
foreign key(car_id) REFERENCES Car(car_id)
);
create table ServiceTicket(
service_id INTEGER PRIMARY KEY,
customer_id INTEGER,
carSerialNumber VARCHAR(10),
serviceDate date,
description VARCHAR(300),
foreign key (customer_id) REFERENCES Customer(customer_id)
);
create table mechanicService(
mechanic_id INTEGER,
service_id INTEGER,
foreign key (mechanic_id) REFERENCES Mechanic(mechanic_id),
foreign key(service_id) references ServiceTicket(service_id)
);
create table CarDealerShip(
carSerialNumber INTEGER,
service_id INTEGER,
foreign key(service_id) references ServiceTicket(service_id)
);