The following relations keep track of airline flight information:
- Flights(flno: integer, from: string, to: string, distance: integer, departs: time, arrives: time, price: integer)
- Aircraft(aid: integer, aname: string, cruisingrange: integer)
- Certified(eid: integer, aid: integer)
- Employees(eid: integer, ename: string, salary: integer)
Note that 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.
First, create these tables in SQLite. Add at least 6 rows of data for each table, so you will have some information to test.
Next, write each of the following queries in SQL.
- Find the eids of pilots certied for some Boeing aircraft.
- Find the names of pilots certied for some Boeing aircraft.
- Find the aids of all aircraft that can be used on non-stop flights from Bonn to Madras.
- Identify the flights that can be piloted by every pilot whose salary is more than $100,000.
- Find the names of pilots who can operate planes with a range greater than 3,000 miles but are not certied on any Boeing aircraft.
- Find the eids of employees who make the highest salary.
- Find the eids of employees who make the second highest salary.
- Find the eids of employees who are certied for the largest number of aircraft.
- Find the eids of employees who are certied for exactly three aircraft.
- Find the total amount paid to employees as salaries.
- Find the names of aircraft such that all pilots certified to operate them earn more than 80,000.
- For each pilot who is certified for more than three aircraft, find the eid and the maximum cruisingrange of the aircraft that he (or she) is certified for.
- Find the names of pilots whose salary is less than the price of the cheapest route from Los Angeles to Honolulu.
- For all aircraft with cruisingrange over 1,000 miles, find the name of the aircraft and the average salary of all pilots certified for this aircraft.
- Find the names of pilots certified for some Boeing aircraft.
- Find the aids of all aircraft that can be used on routes from Los Angeles to Chicago.
- Identify the routes that can be piloted by every pilot who makes more than $100,000.
- Print the enames of pilots who can operate planes with cruisingrange greater than 3,000 miles, but are not certified on any Boeing aircraft.
- A customer wants to travel from Madison to New York with no more than two changes of flight. List the choice of departure times from Madison if the customer wants to arrive in New York by 6 p.m.
- Compute the difference between the average salary of a pilot and the average salary of all employees (including pilots).
- Print the name and salary of every nonpilot whose salary is more than the average salary for pilots.