04 Airline DB
04 Airline DB
FLIGHTS (fno: varchar, from: string, to: string, distance: integer, departs: time, arrives: time, price:
integer)
AIRCRAFT (aid: varchar, aname: string, cruisingrange: integer) CERTIFIED (eid: varchar, aid:
varchar)
EMPLOYEES (eid: varchar, ename: string, salary: integer)
Note: The Employees relation describes pilots and other kinds of employees as well; Every pilot is certified
for some aircraft, and only pilots are certified to fly.
Write SQL queries to
1. Find the names of aircraft such that all pilots certified to operate them have salaries more than Rs.80, 000.
SELECT ANAME
FROM AIRCRAFT A, CERTIFIED C, EMPLOYEES E
WHERE A.AID=C.AID AND C. EMP_ID =E. EMP_ID AND E.SALARY >80000;
2. For each pilot who is certified for more than three aircrafts, find the eid and the maximum
cruisingrange of the aircraft for which she or he is certified.
3. Find the names of pilots whose salary is less than the price of the cheapest route from Bengaluru to
Mumbai.
4. Find the aids of all aircraft that can be used on routes from Bengaluru to New Delhi.
SELECT A. AID
FROM AIRCRAFT A , FLIGHT F
WHERE A.AID=F.FLIGHT_NUM AND F.from=‘BENGALURU’ AND F.to= ‘NEW DELHI’;
4. Find the employee name and salary earning second highest salary.