-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflightDDL.sql
96 lines (87 loc) · 2.12 KB
/
flightDDL.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
create table users
(
uname varchar(20) not null,
passwd varchar(100) not null,
pno varchar(20) not null,
first_name varchar(20) not null,
last_name varchar(20) not null,
DOB date not null,
phone_no int(10) not null,
address varchar(50),
primary key(uname)
);
create table userMakesPayment
(
uname varchar(20),
ticket_id varchar(10),
primary key (uname, ticket_id),
foreign key (uname) references users (uname)
on delete cascade,
foreign key (ticket_id) references ticket (ticket_id)
on delete cascade
);
create table ticket
(
ticket_id varchar(10) not null,
uname varchar(20),
flight_id varchar(10),
status varchar(10),
price int,
primary key(ticket_id),
foreign key (uname) references users (uname)
on delete set null,
foreign key (flight_id) references flight (flight_id)
on delete cascade
);
create table booking
(
ticket_id varchar(10),
flight_id varchar(10),
foreign key (ticket_id) references ticket (ticket_id)
on delete set null,
foreign key (flight_id) references flight (flight_id)
on delete cascade
);
create table flight
(
flight_id varchar(10) not null,
arrival time,
departure time,
source varchar(15) not null,
destination varchar(15) not null,
route varchar(10),
model varchar(15),
manufacturer varchar(15),
count_ticket int,
primary key(flight_id)
);
create table flightScheduledForAirline
(
airline_id varchar(10),
flight_id varchar(10),
foreign key (airline_id) references airline (airline_id)
on delete cascade,
foreign key (flight_id) references flight (flight_id)
on delete set null
);
create table airline
(
airline_id varchar(10) not null,
airline_name varchar(20),
primary key(airline_id)
);
create table airportContainsAirline
(
airline_id varchar(10),
location_code varchar(4),
foreign key (airline_id) references airline (airline_id)
on delete cascade,
foreign key (location_code) references airport (location_code)
on delete cascade
);
create table airport
(
location_code varchar(4) not null,
city varchar(15) not null,
primary key(location_code)
);