forked from talal1086/FlightReservation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flightReservation.sql
59 lines (49 loc) · 1.28 KB
/
flightReservation.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
CREATE DATABASE IF NOT EXISTS RESERVATION;
USE RESERVATION;
CREATE TABLE IF NOT EXISTS USER
(
ID INT NOT NULL AUTO_INCREMENT,
FIRST_NAME VARCHAR(20),
LAST_NAME VARCHAR(20),
EMAIL VARCHAR(20),
PASSWORD VARCHAR(256),
PRIMARY KEY (ID),
UNIQUE KEY (EMAIL)
);
CREATE TABLE IF NOT EXISTS FLIGHT
(
ID INT NOT NULL AUTO_INCREMENT,
FLIGHT_NUMBER VARCHAR(20) NOT NULL,
OPERATING_AIRLINES VARCHAR(20) NOT NULL,
DEPARTURE_CITY VARCHAR(20) NOT NULL,
ARRIVAL_CITY VARCHAR(20) NOT NULL,
DATE_OF_DEPARTURE DATE NOT NULL,
ESTIMATED_DEPARTURE_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (ID)
);
CREATE TABLE IF NOT EXISTS PASSENGER
(
ID INT NOT NULL AUTO_INCREMENT,
FIRST_NAME VARCHAR(256),
LAST_NAME VARCHAR(256),
MIDDLE_NAME VARCHAR(256),
EMAIL VARCHAR(50),
PHONE VARCHAR(10),
PRIMARY KEY (ID)
);
CREATE TABLE IF NOT EXISTS RESERVATION
(
ID INT NOT NULL AUTO_INCREMENT,
CHECKED_IN TINYINT(1),
NUMBER_OF_BAGS INT,
PASSENGER_ID INT,
FLIGHT_ID INT,
CREATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (ID),
FOREIGN KEY (PASSENGER_ID) REFERENCES PASSENGER(ID) ON DELETE CASCADE,
FOREIGN KEY (FLIGHT_ID) REFERENCES FLIGHT(ID)
);
SELECT * FROM USER;
SELECT * FROM PASSENGER;
SELECT * FROM FLIGHT;
SELECT * FROM RESERVATION;