-
Notifications
You must be signed in to change notification settings - Fork 0
/
database table sql codes.txt
97 lines (73 loc) · 2.38 KB
/
database table sql codes.txt
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
CREATE TABLE customer(
first_name char(40),
last_name char(40),
customer_name char(40),
email char(40),
phone int,
phone char(40),
pass char(40),
PRIMARY KEY (email)
)
CREATE TABLE admin(
admin_name char(40),
email char(40),
pass char(40),
PRIMARY KEY (email)
)
CREATE TABLE airline (
email CHAR(40) PRIMARY KEY,
pass CHAR(40),
airline_name CHAR(40) UNIQUE,
logo CHAR(40)
);
CREATE TABLE airport (
airport_id INT AUTO_INCREMENT PRIMARY KEY,
airport_name char(40)
);
CREATE TABLE flight (
id INT AUTO_INCREMENT PRIMARY KEY,
source_date DATE,
source_time TIME,
dest_date DATE,
dest_time TIME,
dep_airport char(40),
arr_airport char(40),
seats INT,
price DECIMAL(12, 2),
flight_class char(40),
airline_name char(40),
dep_airport_id int,
arr_airport_id int,
airline_email char(40),
foreign key(dep_airport_id) references airport(airport_id) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key(arr_airport_id) references airport(airport_id) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key(airline_email) references airline(email) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key(airline_name) references airline(airline_name) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE booked (
id INT AUTO_INCREMENT PRIMARY KEY,
flight_id int,
customer_email char(40),
foreign key(flight_id) references flight(id) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key(customer_email) references customer(email) ON DELETE CASCADE ON UPDATE CASCADE
);
not using
CREATE TABLE booked (
id INT AUTO_INCREMENT PRIMARY KEY,
source_date DATE,
source_time TIME,
dest_date DATE,
dest_time TIME,
dep_airport char(40),
arr_airport char(40),
flight_class char(40),
airline_name CHAR(40),
customer_email char(40),
dep_airport_id int,
arr_airport_id int,
airline_email char(40),
foreign key(customer_email) references customer(email) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key(dep_airport_id) references airport(airport_id) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key(arr_airport_id) references airport(airport_id) ON DELETE CASCADE ON UPDATE CASCADE,
foreign key(airline_email) references airline(email) ON DELETE CASCADE ON UPDATE CASCADE
);