DBMS Lab Da-2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CYCLE SHEET – I

AIRLINE Databases

1. Create the following tables


 AIRPORT(Airport_code, Name, City, State)
 FLIGHT(Flight_number, Airline, Weekdays)
 FLIGHT_LEG(Flight_number, Leg_number, Scheduled_departure_time,
Departure_ airport_code, Arrival_airport_code, Scheduled_arrival_time)
 LEG_INSTANCE(Flight_number, Leg_number, Date,
Number_of_available_seats, Airplane_id, Departure_airport_code,
Departure_time, Arrival_airport_code, Arrival_time )
 FARE(Flight_number, Fare_code, Amount, Restrictions)
 AIRPLANE_TYPE(Airplane_type_name, Max_seats, Company)
 CAN_LAND(Airplane_type_name, Airport_code )
 AIRPLANE(Airplane_id, Total_number_of_seats, Airplane_type)
 SEAT_RESERVATION(Flight_number, Leg_number, Date, Seat_number,
Customer_ name, Customer_phone)
Primary Keys and Foreign Keys are self-explanatory.

Insert at least 10 rows to each table.


(Apply Interactive insertion. Check Entity Integrity Constraint and key Constraint.)

1. Query the Db to display


a) The flight details.
b) Id and type of Airplane.
c) Airports that start with “K”.
d) Airports (name) in Tamilnadu.
e) Seat reservation details for a given customer name and date.
f) Flight numbers that are scheduled on Wednesday or contain India in the name.
g) Airplane details for which type is not known.
h) Flight leg details that has a departure and arrival airport code.
i) Airport details that is not in 'Chennai'...
j) Seat reservation that are made during last month.
k) Fare code for amount in range 21000 to 37000.
l) Airplane company names that contains exactly 3 'S' in it.
m) Flight leg details that has leg #s 1, 3, and 4.
n) Maximum seats in airplane.
o) Number of leg instances of a flight number.
p) Total amount collected as fare for a given flight number.

2. Alter the tables to


a) Add required foreign keys.
b) Insert values to see the referential integrity constraints.
c) Make name of airport as Unique and weekdays as not null.
d) Make weekdays as multivalued attribute. Increase the size of flight airline.
e) Convert fare amount to decimal type.
f) Decrease the size of fare restriction.
g) Add column country in airport table. (Update the table).
h) Add a column address in seat reservation table (as composite attribute).
(Update the table).
i) Delete the column added.

3. Create the following assertions in the above tables.


a) Flight number should be in the range 1000 to 2000.
b) Country in airport must be India, USA, UAE, Malaysia, and South Africa.
c) No of weekdays of flight is not more than 3.

4. Queries on SQL * PLUS functions.


a) Find the flight numbers booked for tomorrow.
b) Print the company name as 'aba' translated to 'ryb'.
c) Print the months between date of reservation and todays date (only unique
dates).
d) Print the Airplane type names in Upper case
e) Print flight numbers with left padded stars.
f) Print the first five characters of customer names.
g) Print the length of longest airport name.
h) Print System date in the format 27 t h Nov 2015.
i) Replace the a‟s present in customer names with „e‟.
j) Print the time in flight leg as hh-ss-mm.
k) Print the date in seat reservation in the format '27/11/2015'.
l) Print the arrival time in 12hr format.
CYCLE SHEET – II
5. Nested Queries.
a) List the airplane id, type and company name.
b) List the airline for which fare is more than 3000.
c) List the airport names which are arrival ports for at least 3 flights.
d) Retrieve airport code that is greater than all airplane id of given airplane type.
e) List the flight number that has no booking.
f) Retrieve the airline names that has at least two bookings.
g) Retrieve the airport code that are only arrival and not departure port.
h) Retrieve the flight numbers that arrive in all the cities of Tamilnadu.
i) Retrieve the country which has more than 10 airports.
j) Find the airline which has highest number of intermediate stoppings.
k) List the flight number, the departure airport for the first leg of the flight, and
the arrival airport for the last leg of the flight.
l) List the flight numbers and weekdays of all flights or flight legs that depart
from Pune Airport (airport code „PNQ‟) and arrive in Los Angeles
International Airport (airport code „LAX‟).
m) List the flight number, departure airport code, scheduled departure time,
arrival airport code, scheduled arrival time, and weekdays of all flights or flight
legs that depart from some airport in the city of Karnataka and arrive at some
airport in the city of Kerala.
n) List all fare information for flight number „CO197‟.
o) Retrieve the number of available seats for flight number „CO197‟ on „30-nov-
2016‟.

6. Miscellaneous
a) Create an empty table myflight with same structure as flight table.
b) Create a table fare with same contents as fare table.
c) Create a table with flightno, legno, arrivalairportcode.
d) Insert values into this table from existing tables.
e) Create a virtual table that contains flightno, arrival airport name.
f) Increase the fare amount by 5%.
g) Create a view for Q.3
h) Create a view with airplane id, company name where
max_seatstotal_number_of_seats>10.
i) Update a company name in the view in Q.7.
j) Display the structure of all tables.
k) Drop the unique constraint added.
l) Create a sequence with minimum value 1 max 200, increment by 2 start with 4
to generate values to the airplane id column.
m) Alter the above sequence to have maximum value 300.
n) Create an index on state column of airport table.
o) Select the flights on Wednesday ('wed'). ( Query with Object type)
p) Write a query to show the constraints (plus column) created on the Table
already existing.
q) Write a query to show the sequences created by the user.
r) Write a query to show the procedures, functions, triggers already created.
s) Write a query to show all the details about constraints.
t) Write a query to see the body of a procedure or function.
u) Write a query to see the body of trigger.

CYCLE SHEET – III


7. PL/SQL
a) Write a PL/SQL block to display the reverse of numbers between 1 and 100.
b) Write a PL/SQL block to find the greatest of three numbers.
c) Write a PL/SQL block to generate Fibonacci series.
d) Write a block to raise an exception if the reservation date is less than today's
date.
e) Write a cursor to give the details of all the flights.
f) Write a cursor to give flight details that range between 1200 and 2900.
g) Write a procedure to accept the customer name and display the reservation
details.
h) Write a procedure (with cursor) to display the company names along with
airplane ids.
i) Write a function to give the number of flights arriving for a given airport code.
j) Write a function to return the airport name which is having highest number of
airplane types landing.
k) Write a trigger to update the airplane type in airplane when parent table is
updated.
l) Write a trigger to delete all the foreign key references when the parent primary
key is deleted. (If you have added cascade while create table ignore this
question.)
m) Write a trigger to raise an exception if reservation date is invalid while
insertion. (Should be latter than current date.)
n) Write a trigger to update the myflight table when flight tuple is inserted.
o) Create a nested table from the airplane database. Create a package with two
functions on the table.

You might also like