0% found this document useful (0 votes)
2 views9 pages

Flight DB

The document outlines the design and functionality of an airline database system, including an Entity-Relationship (ER) diagram, tables for airplanes, flights, passengers, and bookings. It details various views for displaying flight and passenger information, stored functions for calculating available seats and booked passengers, stored procedures for managing bookings, triggers for ensuring data integrity, and events for archiving completed flights. Overall, it provides a comprehensive overview of the database structure and operations necessary for managing airline bookings and passenger data.

Uploaded by

invoker26d2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views9 pages

Flight DB

The document outlines the design and functionality of an airline database system, including an Entity-Relationship (ER) diagram, tables for airplanes, flights, passengers, and bookings. It details various views for displaying flight and passenger information, stored functions for calculating available seats and booked passengers, stored procedures for managing bookings, triggers for ensuring data integrity, and events for archiving completed flights. Overall, it provides a comprehensive overview of the database structure and operations necessary for managing airline bookings and passenger data.

Uploaded by

invoker26d2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Garces, Jonathan M.

Pingen, Denver Ace I.

BSCS 2B
Activity 2

I. Model

Airline ER Diagram

Airline Relationship Model


II. Tables

Airplane Table

Flight Table
Passenger Table

Booking Table
III. Views

It views the flight details (flight number, departure location, and destination) along with the total
number of passengers booked for each flight, including flights with no bookings.

It views the flight details (flight number, departure location, destination, departure date, and
departure time), along with the number of available seats for each flight, by calculating the
difference between the airplane's capacity and the number of passengers booked for the flight. The
data is fetched by joining the Flight, Airplane, and Booking tables, grouped by flight details.
It views the flight details (flight number, departure location, destination, departure date,
departure time, arrival date, arrival time), along with the model number and capacity of the
airplane used for each flight. The data is fetched by joining the Flight and Airplane tables based on
the ModelNumber.

It views the passenger details (passenger ID, given names, surname, email address), along with
their booking ID, flight number, departure city, arrival city, departure date, and departure
time for each booking. The data is fetched by joining the Passenger, Booking, and Flight tables
based on their respective relationships.
It views the passenger details (passenger ID, given names, surname, and email address) from the
Passenger table.

IV. Stored Functions

This stored function calculates and returns the number of available seats for a given flight by
subtracting the number of booked seats from the flight's total capacity.

This stored function calculates and returns the number of booked passengers for a specific flight by
counting the number of bookings associated with that flight.

V. Stored Procedures
This stored procedure checks if a passenger already exists based on their email address; if not, it
inserts the new passenger, then creates a booking record for the passenger and flight, and finally
returns a message confirming the booking.

This stored procedure checks if a booking exists using the provided booking ID; if the booking
exists, it deletes the booking and returns a confirmation message, otherwise, it returns a message
stating that the booking could not be found or canceled.

VI. Triggers
This trigger checks if a flight is fully booked when a new booking is being made; if the number of
booked seats is equal to or greater than the flight's capacity, it raises an error and prevents the
booking from being processed.

This trigger updates the Passenger table with the most recent GivenNames, Surname, and
EmailAddress when a booking is updated, ensuring that the passenger's information remains current
in the database.

VII. Events
This is an Event that automatically moves completed flights (older than 1 year) from the Flight table
to the ArchivedFlight table and deletes those flights from the Flight table, typically to run at a
scheduled time.

This Event updates the status of flights to "Completed" for those that have already passed their
scheduled arrival time, ensuring that flights that have arrived are marked as completed.

You might also like