0% found this document useful (0 votes)
35 views8 pages

An Airline Reservations System

The document describes an airport database system with tables for flights and customers. The flight table stores information about flights while the customer table stores passenger details and linked flight numbers. 10 SQL queries are provided to retrieve information from these tables such as available flights, reserved seats, and arriving passengers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views8 pages

An Airline Reservations System

The document describes an airport database system with tables for flights and customers. The flight table stores information about flights while the customer table stores passenger details and linked flight numbers. 10 SQL queries are provided to retrieve information from these tables such as available flights, reserved seats, and arriving passengers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

AirPort Database System

Project description:

Each flight has a limited number of available seats. There are number
of flights that go from/to different cities at different dates and time.
The system shall maintain a table for the list of available flights
where each row within the table has the following fields: Flight
number,
Departure city, Destination City, Departure date, Departure time,
Arrival date, Arrival Time, Capacity, and Available seats.
The System shall maintain a table for the customers where each row
within the table has the following fields: Confirmation number,
Customer Name, Customer Address, and Departure Flight Number.
The values within this table will be created when the user makes a
reservation.

Requirements:
Draw relationship between entities using Edraw Max , then
Create tables using oracle,. After that write 10 SQL statements
to perform these queries.

The ERD
Create tables using oracle

 Create the flight table


create table flight (
flightNumber number primary key,
departureCity nvarchar2(50),
destinationCity nvarchar2(50),
departureDate date,
departureTime timestamp,
arrivalDate date,
arrivalTime timestamp,
capacity number,
availableSeats number );

 create the customer table


create table customer (
confirmationNumber number primary key,
customerName nvarchar2(50),
customerAddress nvarchar2(50),
flightNumber number,
constraint customer_fk foreign key (flightNumber)
references flight(flightNumber)
);

10 SQL statements to perform these queries

1. How many customers arrived from KSA last week

select count(confirmationNumber)
from customer, flight
where customer.flightNumber = flight.flightNumber
and flight.departureCity = 'KSA'
and flight.arrivalDate between sysdate -7 and sysdate;
2. Display customer name who is registered for two flights last
month.

select customerName
from customer, flight
where customer.flightNumber = flight.flightNumber
and flight.arrivalDate between add_months( sysdate , -1 ) and
sysdate
group by customerName
having count(confirmationNumber) = 2;

3. How many flights that arrived from UK today.

select count(flightNumber)
from flight
where departureCity = 'UK'
and arrivalDate = sysdate;

4. How many customers come on the flights that which


arrived yesterday?

select count(confirmationNumber)
from customer, flight
where customer.flightNumber = flight.flightNumber
and flight.arrivalDate = sysdate - 1;

5. Display the arrival date for the last flight that is coming
from USA

select max(arrivalDate)
from flight
where departureCity = 'USA';
6. Display the nearest flight’s departure date that have two
Seats together for Australia ? ‫يريد تاريخ وموعد أول طائرة متجهة‬
‫الستراليا وبها كرسيين لم يتم حجزهم‬

select max(arrivalDate)
from flight
where departureCity = 'Australia'
and availableSeats >= 2;

7. Show all flights for today and the availability of seats, on


each flight.
‫اذكر بيانت الرحالت التي ستقلع اليوم باإلضافة الى عدد الكراسي المتاحة التي لم‬
‫يتم حجزها في كل رحلة‬

select *
from flight
where departureDate = sysdate;

8. display flights that are less than half full and its departure
date before three days. ‫ ايام وعدد‬3 ‫اذكر الرحالت التي موعد أقالعها بعد‬
‫الكراسي المحجوزة بها أقل من النصف‬

select *
from flight
where departureDate = sysdate + 3
and availableSeats > (capacity / 2);
9. for each flight display customer name, total number of seats
he is reserves. ‫اذكر اسم العميل ورقم الرحلة وعدد الكراسي التي قام بحجزها‬
‫في هذه الرحلة‬

select customerName ,flightNumber ,count(confirmationNumber)


from customer
group by customerName ,flightNumber;

10. Perform a report that display flights that have the


following condition: (0.25 flight capacity < number of
reserved seats < 0.5 flight capacity) and departures date
after 4 dayes))). In order to encourage customers to buy
tickets on that flight. Let the system perform a discount of
%30 of their original price.

select flightNumber ,departureCity ,destinationCity ,departureDate


,departureTime ,arrivalDate ,arrivalTime ,capacity ,availableSeats ,
'the is discount of %30 of their original price of this flight'
from flight
where (capacity - availableSeats ) between (0.5 * capacity) and (0.25
* capacity)
and departureDate = sysdate + 4;
the picture of execution the queries

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy