Assignment 2 Key 8.15
Assignment 2 Key 8.15
Assignment 2 Key 8.15
8.15 Show the result of each of the sample queries in Section 8.5 as it would apply
to the database state in Figure 5.6
Q1. Find the name and address of all employees who work for the 'Research' department.
Q2. For every project located in 'Stafford', list the project number, the controlling department
number, and the department manager's last name, address, and birth date.
Q3. Find the names of all employees who work on all the projects controlled by department number
5.
Q4. Make a list of project numbers for projects that involve an employee whose last name is 'Smith'
as a worker or as a manager of the department that controls the project.
Q5. List the names of all employees with two or more dependents.
8.16
a. Retrieve the names of all employees in department 5 who work more than 10 hours per week on
the ProductX project.
b. List the names of all employees who have a dependent with the same first name as themselves.
c. Find the names of all employees who are directly supervised by ‘Franklin Wong’.
d. For each project, list the project name and the total hours per week (by all employees) spent on
that project.
* You can use operations like count, sum, average, max, min etc. Usage: G ℑ Aggregate-function(A), you can
see an example in above solution.
e. Retrieve the names of all employees who work on every project.
EMPS_ALL_PROJS ← PE ÷ ALL_PROJECTS
f. Retrieve the names of all employees who do not work on any project.
g. For each department, retrieve the department name and the average salary of all employees
working in that department.
j. List the last names of all department managers who have no dependents.
8.17
a. For each flight, 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.
b. List the flight numbers and weekdays of all flights or flight legs that depart from Houston
Intercontinental Airport (airport code ‘iah’) and arrive in Los Angeles International Airport
(airport code ‘lax’).
c. 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 Houston and arrive at some airport in the city of Los Angeles.
RESULT <- πFlight_number, Dep_airport_code, Sched_dep_time, Arr_airport_code, Sched_arrival_time, Weekday (HOUSTON_LA * FLIGHT)
8.18
a. How many copies of the book titled The Lost Tribe are owned by the library branch whose name
is ‘Sharpstown’?
b. How many copies of the book titled The Lost Tribe are owned by each library branch?
c. Retrieve the names of all borrowers who do not have any books checked out.
d. For each book that is loaned out from the Sharpstown branch and whose Due_date is today,
retrieve the book title, the borrower’s name, and the borrower’s address.
e. For each library branch, retrieve the branch name and the total number of books loaned out
from that branch.
f. Retrieve the names, addresses, and number of books checked out for all borrowers who have
more than five books checked out.
g. For each book authored (or coauthored) by Stephen King, retrieve the title and the number of
copies owned by the library branch whose name is Central.