0% found this document useful (0 votes)
25 views2 pages

Airline Database Schema Design

The document defines the schema for an airline database with tables for Airlines, Flights, Tickets, Passengers, Reservations, Employees, and relationship tables to link Passengers to Flights/Tickets and Employees to Flights. Primary and foreign keys are specified to enforce relational integrity between the tables.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Airline Database Schema Design

The document defines the schema for an airline database with tables for Airlines, Flights, Tickets, Passengers, Reservations, Employees, and relationship tables to link Passengers to Flights/Tickets and Employees to Flights. Primary and foreign keys are specified to enforce relational integrity between the tables.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

CREATE TABLE Airline (

airlineId INT PRIMARY KEY,


airlineName VARCHAR(255) NOT NULL
);

CREATE TABLE Flight (


flightNumber INT PRIMARY KEY,
departureDateTime DATETIME NOT NULL,
arrivalDateTime DATETIME NOT NULL,
departureCity VARCHAR(255) NOT NULL,
arrivalCity VARCHAR(255) NOT NULL,
ticketPrice DECIMAL(10,2) NOT NULL,
airlineId INT NOT NULL,
FOREIGN KEY (airlineId) REFERENCES Airline(airlineId)
);

CREATE TABLE Ticket (


ticketNumber INT PRIMARY KEY,
departureDate DATE NOT NULL,
seatNumber VARCHAR(10) NOT NULL,
ticketPrice DECIMAL(10,2) NOT NULL,
flightNumber INT NOT NULL,
FOREIGN KEY (flightNumber) REFERENCES Flight(flightNumber)
);

CREATE TABLE Passenger (


passengerId INT PRIMARY KEY,
passengerName VARCHAR(255) NOT NULL,
passengerEmail VARCHAR(255) NOT NULL,
passengerPhone VARCHAR(20) NOT NULL
);

CREATE TABLE Reservation (


reservationNumber INT PRIMARY KEY,
departureDate DATE NOT NULL,
returnDate DATE NOT NULL,
numOfPassengers INT NOT NULL,
ticketNumber INT NOT NULL,
FOREIGN KEY (ticketNumber) REFERENCES Ticket(ticketNumber)
);

CREATE TABLE Employee (


employeeId INT PRIMARY KEY,
employeeName VARCHAR(255) NOT NULL,
jobTitle VARCHAR(255) NOT NULL,
salary DECIMAL(10,2) NOT NULL
);

CREATE TABLE PassengerFlight (


passengerId INT NOT NULL,
flightNumber INT NOT NULL,
ticketNumber INT NOT NULL,
PRIMARY KEY (passengerId, flightNumber, ticketNumber),
FOREIGN KEY (passengerId) REFERENCES Passenger(passengerId),
FOREIGN KEY (flightNumber) REFERENCES Flight(flightNumber),
FOREIGN KEY (ticketNumber) REFERENCES Ticket(ticketNumber)
);

CREATE TABLE EmployeeFlight (


employeeId INT NOT NULL,
flightNumber INT NOT NULL,
dutyStartTime DATETIME NOT NULL,
dutyEndTime DATETIME NOT NULL,
PRIMARY KEY (employeeId, flightNumber),
FOREIGN KEY (employeeId) REFERENCES Employee(employeeId),
FOREIGN KEY (flightNumber) REFERENCES Flight(flightNumber)
);

Common questions

Powered by AI

Introduce a new table, ServiceClass, linked to the Ticket table, where each seat corresponds to a service class, such as Economy or Business. This allows differentiation of ticket prices based on class and extends flexibility in ticket management. Ensure ServiceClass details align with existing records, enabling seamless integration .

Third-party integration requires modifications to store additional data, such as weather forecasts. This might involve creating a new Weather table linked with Flight records, storing forecast data relevant to departure and arrival cities. Architectural changes may be needed to handle dynamic data updates and ensure system resiliency .

Implementing transaction management with ACID properties (Atomicity, Consistency, Isolation, Durability) ensures consistent data states. Utilize database locking mechanisms to prevent conflicts during simultaneous operations, and consider using optimistic concurrency control to handle conflicts gracefully .

The primary integrity issues could include orphan records due to incorrect foreign key references, such as a Ticket referencing a non-existent Flight. To resolve this, utilize cascading actions (e.g., ON DELETE CASCADE) to ensure that deleting a Flight automatically deletes associated Tickets and Reservations. Confirm all foreign keys correctly match primary keys, and implement constraints to prevent null values where not allowed (e.g., flightNumber in Ticket).

Foreign keys enforce relationships by ensuring that values in columns depend on values in another table. For example, a Ticket's flightNumber must exist in the Flight table, reinforcing the relationship that each Ticket is associated with a Flight. This ensures integrity, as a Ticket cannot exist without a corresponding flight, preventing invalid data scenarios .

Scalability challenges include handling vast amounts of data without performance degradation. Indexing critical fields (e.g., flightNumber, passengerId) could improve query speed, but additional architecture layers (e.g., sharding, partitioning) might be needed to distribute data efficiently. The schema may require further normalization to maintain efficiency and simplicity .

The schema reflects a normalized structure, likely in third normal form (3NF). Each table avoids redundancy by splitting data into separate entities: Airline, Flight, Ticket, and Passenger. For example, flight details are isolated in the Flight table, ensuring changes to flight information do not affect other tables. This reduces anomalies and maintains data integrity .

The PassengerFlight table could impact performance positively through efficient retrieval of passenger flight history using indexed columns, leading to fast JOIN operations with Passenger and Flight tables. However, a high volume of records may necessitate indexing strategies to avoid slow queries over time .

Consider adding an Availability table to capture employee availability and avoid double-booking. Enhance the EmployeeFlight table to include constraints or indices that flags overlapping duty schedules. Incorporating a scheduling algorithm could optimize coverage and account for rest periods between duties .

The schema is somewhat flexible but adding a loyalty program would likely require a new table (e.g., LoyaltyProgram) linked to the Passenger table. This addition allows tracking of points, status, and rewards, without altering existing records. Consider how these new relationships interact with ticket purchases to maintain data consistency .

You might also like