0% found this document useful (0 votes)
7 views1 page

04 Airline DB

Database management system airline

Uploaded by

M Krithika
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)
7 views1 page

04 Airline DB

Database management system airline

Uploaded by

M Krithika
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/ 1

Consider the schema for Airline Database:

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.

SELECT C. EMP_ID, MAX(A.CRUISINGRANGE)


FROM AIRCRAFT A, CERTIFIED C
WHERE A.AID=C.AID
GROUP BY EMP_ID HAVING COUNT(AID)>3;

3. Find the names of pilots whose salary is less than the price of the cheapest route from Bengaluru to
Mumbai.

SELECT DISTINCT ENAME FROM EMPLOYEES E, CERTIFIED C, AIRCRAFT A, FLIGHT F


WHERE E.EMP_ID =C.EMP_ID AND C.AID=A.AID AND A.AID=F. FLIGHT_NUM AND
E.SALARY < ( SELECT MIN(PRICE)
FROM FLIGHT
WHERE from=’BANGALORE’ AND 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.

SELECT ENAME, MAX(SALARY) AS SALARY


FROM EMPLOYEES
WHERE SALARY IN
(SELECT SALARY FROM EMPLOYEE MINUS SELECT MAX(SALARY)
FROM EMPLOYEES);

You might also like