Unformatted text preview:

COP5725 Database Management Systems - Fall 2006 Homework 3 Due: 09/21/06 Exercise 5.3 The following relations keep track of airline flight information: Flights(flno: integer, from: string, to: string, distance: integer, departs: time, arrives: time, price: real) 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. Write each of the following queries in SQL. 1. Find the names of aircraft such that all pilots certified to operate them have salaries more than $80,000. 2. For each pilot who is certified for more than three aircraft, 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 Los Angeles to Honolulu. 4. For all aircraft with cruisingrange over 1000 miles, find the name of the aircraft and the average salary of all pilots certified for this aircraft. 5. Find the names of pilots certified for some Boeing aircraft. 6. Find the aids of all aircraft that can be used on routes from Los Angeles to Chicago. 7. Identify the routes that can be piloted by every pilot who makes more than $100,000. 8. Print the enames of pilots who can operate planes with cruisingrange greater than 3000 miles but are not certified on any Boeing aircraft. 9. 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. 10. Compute the difference between the average salary of a pilot and the average salary of all employees (including pilots). 11. Print the name and salary of every nonpilot whose salary is more than the average salary for pilots.12. Print the names of employees who are certified only on aircrafts with cruising range longer than 1000 miles. 13. Print the names of employees who are certified only on aircrafts with cruising range longer than 1000 miles, but on at least two such aircrafts. 14. Print the names of employees who are certified only on aircrafts with cruising range longer than 1000 miles and who are certified on some Boeing aircraft. Exercise 5.4 Consider the following relational schema. An employee can work in more than one department; the pct_time field of the Works relation shows the percentage of time that a given employee works in a given department. Emp(eid: integer, ename: string, age: integer, salary: real) Works(eid: integer, did: integer, pct_time: integer) Dept(did: integer, dname: string, budget: real, managerid: integer) Write the following queries in SQL: 1. Print the names and ages of each employee who works in both the Hardware department and the Software department. 2. For each department with more than 20 full-time-equivalent employees (i.e., where the part-time and full-time employees add up to at least that many full-time employees), print the did together with the number of employees that work in that department. 3. Print the name of each employee whose salary exceeds the budget of all of the departments that he or she works in. 4. Find the managerids of managers who manage only departments with budgets greater than $1 million. 5. Find the enames of managers who manage the departments with the largest budgets. 6. If a manager manages more than one department, he or she controls the sum of all the budgets for those departments. Find the managerids of managers who control more than $5 million. 7. Find the managerids of managers who control the largest amounts. 8. Find the enames of managers who manage only departments with budgets larger than $1 million, but at least one department with budget less than $5 million.


View Full Document

UF COP 5725 - Homework 3

Documents in this Course
Load more
Download Homework 3
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework 3 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework 3 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?