Midterm Database
Midterm Database
Objective: Design a table to store airport information with appropriate data types
and constraints.
Columns: airport_id (integer), airport_name (string), country (string), state (string),
city (string), created_at (timestamp), updated_at (timestamp).
Requirements: Use appropriate data types, set airport_id as a primary key, and
ensure that timestamps for creation and update are managed automatically.
Objective: Populate the passengers table with diverse entries to reflect a variety of
passengers.
Data Points: Include first name, last name, gender, date of birth, citizenship,
residence, and passport number.
Challenge: Insert at least 2 records with varying data, ensuring the inclusion of
diEerent nationalities and age groups.
Task 5a: Retrieve All Passengers with Their Corresponding Baggage Information
(using dump file)
Objective: Use an INNER JOIN to display joined data from the passengers and
baggage tables.
Details: Show all columns from both tables where records exist in both.
Task 6a: List All Passengers and Any Baggage They Might Have Checked In
(using dump file)
Objective: Implement a LEFT JOIN to show all passengers and their baggage,
including those without any baggage.
Output: Include null values where no baggage is associated.
Task 7a: List All Baggage and the Passengers Associated with Them (using dump
file)
Objective: Use a RIGHT JOIN to display all baggage and link each to a passenger if
available.
Challenge: Display passenger details for each piece of baggage, even if no
passenger data is linked.
Task 8a: Combine Passenger Information with Their Baggage, Showing All
Records(using dump file)
Objective: Use a FULL OUTER JOIN to create a comprehensive list of all passengers
and baggage records.
Complexity: Handle cases where there are passengers without baggage and
baggage without registered passengers.
Objective: Insert data representing a new flight, including all necessary details.
Data Points: Flight ID, departing and arriving gates, linked airline, and timestamps.
Challenge: Ensure that the data adheres to the constraints set by foreign keys and
scheduled times.
Task 5b: List All Flights Along with Airline Names(using dump file)
Objective: Use an INNER JOIN to correlate flights with their respective airlines.
Details: Display flight details alongside the airline names.
Task 6b: Show All Flights, Including Those Without a Registered Airline(using
dump file)
Objective: Implement a LEFT JOIN to list all flights, ensuring those without a linked
airline are included.
Output: Display flights with null values for airlines where applicable.
Task 7b: Display All Airlines and Their Flights(using dump file)
Objective: Use a RIGHT JOIN to show all airlines and their associated flights.
Challenge: Ensure all airlines are listed, even those without current flights.
Task 8b: Merge Details of Flights with Airlines, Showing All Records(using dump
file)
Objective: Use a FULL OUTER JOIN to display a complete set of records from both
flights and airlines.
Complexity: Handle mismatches where flights might not have an airline and vice
versa.
Task 9b: Index the Departure and Arrival Gates in the Flights Table(using dump
file)
Objective: Populate the table with details of baggage checked in for various flights.
Data Points: Include baggage weight and associated booking ID.
Challenge: Ensure all entries are valid and comply with airline baggage policies.
Objective: Remove records for baggage that was withdrawn or not loaded onto the
flight.
Condition: Specify conditions such as baggage not linked to any current booking.
Task 5c: Display All Security Checks Along with Passenger Details(using dump
file)
Objective: Implement a LEFT JOIN to list all passengers, showing those without a
security check record as well.
Output: Include null values for security check details where no checks have been
performed.
Task 7c: Show All Security Checks and Related Passenger Information(using
dump file)
Objective: Use a RIGHT JOIN to ensure all security checks are listed along with
linked passenger data.
Challenge: Display all security check records, filling in passenger details where
available.
Objective: Use a FULL OUTER JOIN to show a comprehensive list including all
security checks and passenger records.
Complexity: Handle cases where there may be security checks or passengers
listed without corresponding matches.
Objective: Establish a table to manage security check records with detailed fields.
Columns: Security check ID, check result, related passenger ID, and timestamps.
Requirements: Include a foreign key to link to passengers, ensuring relational
integrity.
Objective: Populate the security check table with new entries reflecting the
outcomes of checks.
Data Points: Include the result of the security check and the associated passenger
ID.
Challenge: Ensure that all records are linked correctly to existing passenger
records.
Objective: Update records in the security check table to reflect changes in the
security status or error corrections.
Scenario: Amend entries where initial results were recorded incorrectly.
Task 5d: Show Bookings and Their Corresponding Flight Details(using dump
file)
Objective: Use an INNER JOIN to display detailed information linking bookings with
flights.
Details: Present complete booking details alongside the respective flight
information.
Task 6d: Show All Bookings, Including Ones Without Flight Details(using dump
file)
Objective: Implement a LEFT JOIN to list all bookings, accounting for those without
associated flight details.
Output: Display all booking records with null values for any missing flight data.
Task 7d: Show All Flight Details and Associated Bookings(using dump file)
Objective: Use a RIGHT JOIN to ensure all flight records are shown along with any
linked bookings.
Challenge: Display all flights, particularly focusing on those with associated
booking details.
Task 8d: Link Bookings with Flights, Showing All Combinations(using dump file)