| 1 | create table ApplicationUser(
|
|---|
| 2 | UserID INT PRIMARY KEY,
|
|---|
| 3 | Name varchar(255),
|
|---|
| 4 | Surname varchar(255),
|
|---|
| 5 | Email varchar(255),
|
|---|
| 6 | Password varchar(255),
|
|---|
| 7 | PhoneNumber varchar(20),
|
|---|
| 8 | DateJoined date
|
|---|
| 9 | );
|
|---|
| 10 |
|
|---|
| 11 | create table Destination(
|
|---|
| 12 | DestinationID int primary key,
|
|---|
| 13 | Name varchar(255),
|
|---|
| 14 | Country varchar(255),
|
|---|
| 15 | Description text,
|
|---|
| 16 | PopularAttraction text,
|
|---|
| 17 | BestTimeToVisit varchar(255)
|
|---|
| 18 | );
|
|---|
| 19 |
|
|---|
| 20 | create table Airport(
|
|---|
| 21 | AirportID int primary key,
|
|---|
| 22 | Name varchar(255),
|
|---|
| 23 | CityID int,
|
|---|
| 24 | Country varchar(255),
|
|---|
| 25 | Code varchar(3),
|
|---|
| 26 | foreign key (CityID) references Destination(DestinationID)
|
|---|
| 27 | );
|
|---|
| 28 |
|
|---|
| 29 | create table Flight(
|
|---|
| 30 | FlightID int primary key,
|
|---|
| 31 | FlightNumber varchar(50),
|
|---|
| 32 | DepartureAirport int,
|
|---|
| 33 | ArrivalAirport int,
|
|---|
| 34 | DepartureTime time,
|
|---|
| 35 | ArrivalTime time,
|
|---|
| 36 | Price decimal(10,2),
|
|---|
| 37 | AvailableSeats int,
|
|---|
| 38 | foreign key (ArrivalAirport) references Airport(AirportID),
|
|---|
| 39 | foreign key (DepartureAirport) references Airport(AirportID)
|
|---|
| 40 | );
|
|---|
| 41 |
|
|---|
| 42 | create table Booking(
|
|---|
| 43 | BookingID int primary key ,
|
|---|
| 44 | UserID int,
|
|---|
| 45 | FlightID int,
|
|---|
| 46 | BookingDate date,
|
|---|
| 47 | PaymentStatus varchar(20) check(PaymentStatus in ('Pending','Completed','Cancelled')),
|
|---|
| 48 | TotalCost decimal(10,2),
|
|---|
| 49 | SeatNumber int,
|
|---|
| 50 | foreign key (UserID) references ApplicationUser(UserID),
|
|---|
| 51 | foreign key (FlightID) references Flight(FlightID)
|
|---|
| 52 | );
|
|---|
| 53 |
|
|---|
| 54 | create table Review(
|
|---|
| 55 | ReviewID int primary key ,
|
|---|
| 56 | UserID int,
|
|---|
| 57 | TargetID int,
|
|---|
| 58 | ReviewComment text,
|
|---|
| 59 | Rating int,
|
|---|
| 60 | Date date,
|
|---|
| 61 | foreign key (UserID) references ApplicationUser(UserID),
|
|---|
| 62 | constraint FK_TargetID_Flight foreign key (TargetID) references Flight(FlightID) on delete cascade ,
|
|---|
| 63 | constraint FK_TargetID_Destination foreign key (TargetID) references Destination(DestinationID) on delete cascade
|
|---|
| 64 | );
|
|---|
| 65 |
|
|---|
| 66 | create table Payment(
|
|---|
| 67 | PaymentID int primary key,
|
|---|
| 68 | BookingID int,
|
|---|
| 69 | UserID int,
|
|---|
| 70 | PaymentMethod varchar(20) check (PaymentMethod in ('Credit card', 'Debit card', 'PayPal')),
|
|---|
| 71 | Amount decimal(10,2),
|
|---|
| 72 | TransactionDate date,
|
|---|
| 73 | PaymentStatus varchar(20) check (PaymentStatus in ('Success', 'Failed', 'Processing')),
|
|---|
| 74 | foreign key (BookingID) references Booking(BookingID),
|
|---|
| 75 | foreign key (UserID) references ApplicationUser(UserID)
|
|---|
| 76 | );
|
|---|
| 77 |
|
|---|
| 78 | create table Notification(
|
|---|
| 79 | NotificationID int primary key,
|
|---|
| 80 | UserID int,
|
|---|
| 81 | Message text,
|
|---|
| 82 | Type varchar(20) check ( Type in ('Booking confirmation','Flight delay','General update')),
|
|---|
| 83 | DateSent date,
|
|---|
| 84 | foreign key (UserID) references ApplicationUser(UserID)
|
|---|
| 85 | );
|
|---|
| 86 |
|
|---|
| 87 | create table Wishlist(
|
|---|
| 88 | WishlistID int primary key ,
|
|---|
| 89 | UserID int,
|
|---|
| 90 | TargetID int,
|
|---|
| 91 | DateAdded date,
|
|---|
| 92 | foreign key (UserID) references ApplicationUser(UserID),
|
|---|
| 93 | constraint FK_TargetID_Flight foreign key (TargetID) references Flight(FlightID) on delete cascade ,
|
|---|
| 94 | constraint FK_TargetID_Destination foreign key (TargetID) references Destination(DestinationID) on delete cascade
|
|---|
| 95 | );
|
|---|
| 96 |
|
|---|
| 97 | create table Administrator
|
|---|
| 98 | (
|
|---|
| 99 | AdminID int primary key,
|
|---|
| 100 | Email varchar(255)
|
|---|
| 101 |
|
|---|
| 102 | );
|
|---|
| 103 |
|
|---|
| 104 | create table SupportTicket(
|
|---|
| 105 | TicketID int primary key ,
|
|---|
| 106 | UserID int,
|
|---|
| 107 | Subject varchar(255),
|
|---|
| 108 | Description text,
|
|---|
| 109 | Status varchar(20) check ( Status in ('Open','In progress','Resolved')),
|
|---|
| 110 | DateCreated date,
|
|---|
| 111 | DateResolved date,
|
|---|
| 112 | AssignedTo int,
|
|---|
| 113 | foreign key (UserID) references ApplicationUser(UserID),
|
|---|
| 114 | foreign key (AssignedTo) references Administrator(AdminID)
|
|---|
| 115 | ); |
|---|