CSc 4710/6710 Database Systems
Fall 2011
Homework 7
Due: December 11, 2011 (Sunday)
Write and test XQuery expressions for the following queries:
- Retrieve the names and addresses of employees who work for the “Research”
department.
- 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.
- List the names of employees in department 5 who work more than 10 hours
per week on the ProductX project.
- List the names of employees who have a dependent with the same first name
as themselves.
- List the names of employees who are directly supervised by Franklin Wong.
- List the names of employees who work on every project.
- List the names of employees who do not work on any project.
- 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.
- List the names of department managers who have no dependents.
- List the names of employees whose supervisor's supervisor has
a social security number of 888665555.
- 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
/