CSc 4710/6710 Database Systems
Fall 2011
Homework 7
Due: December 11, 2011 (Sunday)

Write and test XQuery expressions for the following queries:

  1. Retrieve the names and addresses of employees who work for the “Research” department.
  2. For every project located in “Stafford”, retrieve the project number, the controlling department number, and the department’s manager’s last name, address, and birth date.
  3. List the names of employees in department 5 who work more than 10 hours per week on the ProductX project.
  4. List the names of employees who have a dependent with the same first name as themselves.
  5. List the names of employees who are directly supervised by Franklin Wong.
  6. List the names of employees who work on every project.
  7. List the names of employees who do not work on any project.
  8. List the names and addresses of employees who work on at least one project located in Houston but whose department has no location in Houston.
  9. List the names of department managers who have no dependents.
  10. List the names of employees whose supervisor's supervisor has a social security number of 888665555.
  11. List the name(s) of employee(s) with the lowest salary.

SUBMISSION Format: Submit text file hw8.sql as follows.

------------------------------------------------------------------
-- HW8 XQuery Queries
-- LAST NAME, First Name
-- CSc 4710/6710 Fall 2011
------------------------------------------------------------------
--
set long 1024
--
-- Query 1
-- Get all students.
--
xquery
let $d := doc("/public/book/company.xml")
for $s in $d/gradebook/students/student
return $s
/
--
-- Query 2 
-- Get distinct student id values from all  nodes.
--
xquery
let $d := doc("/public/book/company.xml")
for $c in distinct-values($d//enroll/@sid)
return $c
/