Sie sind auf Seite 1von 13

DATA BASE AND MANAGEMENT SYSTEM

CYCLE SHEET-II

BY

16MIS0318 - Y.V.B.MANIKANTA

SLOT: L21+L22

FACULTY: MOHAN KUMAR P


PROGRAMS:
1)List the airplane id,type and company name.
SQL>select airplane_id,airplane_type_name,company from
airplane,airplane_type where
airplane.airplane_type=airplane_type.airplane_type_name and airplane_type in
(select airplane_type_name from airplane_type );

2)List the airline for which fare is more than 3000.


SQL> select fl.airline from flight fl,farefa where
fl.flight_number=fa.flight_number and fl.flight_number in(select flight_number
from fare where amount>3000);

3)List the airport names which are arrival ports for atleast 3 flights.
SQL> SQL> select count(*) from airport a join leg_instance l on
a.airport_code=l.arrival_airport_code group by name having count(*)>=3;
4)Retrieve airport code that is greater than all airplane id of given airplane
type.
SQL> select a.airport_code from airport a,airplane a1 where
length(a.airport_code)>length(a1.airplane_id) and
a1.airplane_type=’&airplane_type’;
Output:- no rows selected
5)List the flight number that has no booking
SQL (select f.flight_number from flight f) minus (select s.flight_number from
seat_reservation s);

6)Retrieve the airline names that has at least two bookings.


SQL> SQL> select f.airline from flight f join seat_reservation s on
f.flight_number=s.flight_number group by airline having count(*)>=2;

7)Retrieve the airport code that are only arrival and not departure port.
SQL> select a.airport_code from airport a ,flight_leg f where
a.airport_code=f.arrival_airport_code and a.airport_code not in (select
departure_airport_code from flight_leg) and a.airport_code in(select
arrival_airport_code from flight_leg);
Output:- no rows selected
8)Retrieve the flight numbers that arrive in all the cities of Tamilnadu.
SQL> select f.flight_number from flight_legf,airport a where
a.airport_code=f.arrival_airport_code and a.state=’Tamil Nadu’;
Or
SQL> select f.flight_number from flight_leg f join airport a on
a.airport_code=f.arrival_airport_code and a.state='Tamil Nadu'; OUTPUT:- NO
ROWS SELECTED.
9)Retrieve the country which has more than 10 airports
SQL> select country from airport group by country having count(*)>=10;

10. Find the airline which has highest number of intermediate stoppings
SQL>select airline from flight where flight_numberin(select flight_number
from flight_leg group by flight_number having count(*)=(select
max(count(leg_number)) from flight_leg group by flight_number));

11. 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.
SQL> select flight_number,departure_airport_code,arrival_airport_code from
flight_leg where departure_airport_code=(select min(departure_airport_code)
from flight_leg)
(or)
SQL>select flight_number,departure_airport_code,arrival_airport_code from
leg_instance where leg_number in(select min(leg_number)from leg_instance) or
leg_number in(select max(leg_number)from leg_instance);
Output:- FLIGHT_NUM DEPARTURE_AIRPORT_CODE
ARRIVAL_AIRPORT_CODE
108 MAA HYD
127 PNQ AUH
142 ORD DOH
18115 DEL BLR
3710 PNQ DEL
511 BLR MAA
6 rows selected.
12. 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’).
SQL> select f.flight_number,f.weekdays from flight f,flight_legfl where
f.flight_number=fl.flight_number and departure_airport_code='PNQ' and
arrival_airport_code='LAX';
Output:- no rows selected
13. 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.
SQL>
selectfl.flight_number,fl.scheduled_departure_time,fl.departure_airport_code
,fl.arrival_airport_code,fl.scheduled_arrival_time,f.weekdays,a.city from airport
a,flightf,flight_legfl where a.airport_code=fl.arrival_airport_code and
fl.flight_number=f.flight_number and a.city in('Karnataka','Kerla');
Output:- no rows selected
14. List all fare information for flight number ‘63072’.
SQL> select * from fare where flight_number=’63027’;

15. Retrieve the number of available seats for flight number ‘60372’//Flight
details not available in database choosing flight number “60372” and travel
date “30-nov-16”.
SQL> select leg_number,number_of_available_seats from leg_instance where
flight_number=’60372’ and travel_date='30-NOV-16';
MISCELLANEOUS
1).Create an empty table my flight with same structure as flight table.
SQL> create table my flight as (select * from flight where 0=1);

2). Create a table fare with same contents as fare table.

3).Create a table with flightno,legno,arrivalairportcode. Insert values into


this table from existing tables.
SQL>create table flight_leg1 as select flight_number “flight_number"
,leg_number"leg_number",arrival_airport_code "arrival_airport_code" from
flight_leg;
4).Create a virtual table that contains flight no,arrival airport name.
SQL>create view flight_leg2 as (select f.flight_number,a.name from
flight_legf,airport a where f.arrival_airport_code=a.airport_code);

5). Increase the fare amount by 5%


6).Create a view for Q.3
SQL>create view flight_leg3 as (select flight_number
"flight_number",leg_number "leg_number",arrival_airport_code
"arrival_airport_code" from flight_leg);
7) Create a view with airplane id,company name where
max_seatstotal_number_of_seats>10 SQL>create view derivedtable1 as
(select a.airplane_id,a1.company from airplane a,airplane_type a1 where
a.airplane_type=a1.airplane_type_name and at.max_seats-
a.total_number_of_seats>10);

8) Update a company name in the view in Q.7


. SQL>cannot modify a column which maps to a non-key-preserved table
9).Describe all the tables
10).Drop the unique constraint added.
SQL> select constraint_name from user_constraints where
table_name='AIRPORT';
SQL> alter table airport drop constraint SYS_C00134027;

11).Create a sequence with minimum value 1 max 200 ,increment by 2 start


with 4 to generate values to the airplane id column.
SQL> create sequence sequence1 start with 4 increment by 2 maxvalue 200
minvalue 1;
SQL> update airplane set airplane_id=sequence1.nextval;

12).Alter the above sequence to have maximum value 300.


SQL> alter sequence sequence1 maxvalue 300;
13).Create an index on state column of airport table.
SQL> create index index1 on airport (state);

14.)Select the flights on wednesday('wed'). ( Query with Object type)


SQL> select * from flight per where exists (select 1 from table(per.weekdays)
where column_value like '%wed%');

15). Write a query to show the constraints(plus column) created on the


Table already existing.
SQL> SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS
WHERE TABLE_NAME='FLIGHT_LEG';

Das könnte Ihnen auch gefallen