Assignment #3 - The University of Winnipeg

advertisement
Database System - Assignment #3
Assignment #3
due Wed., Nov. 14, 2012
1. (30) Exercise 7.17 on Page 235
Show the result of the following queries as they would apply to the
database of Figure 7.6 (using the figures available on my home page).
(a) Retrieve the name and address of all employees who
work for the ‘research’ department:
RESEARCH_DEPT  DNAME = ‘Research’(DEPARTMENT)
RESEARCH_EMPS  (RESEARCH_EPT
DNUMBER = DNO EMPLYEE
)
RESULT  FNAME, LNAME, ADDRESS(RESEARCH_EMPS)
Sept. 2012
Yangjun Chen
ACS-3902
1
Database System - Assignment #3
(b) For every project located in ‘Stafford’, list the project number, the controlling
department number, and the department manager’s last name, address, and the
birthdate.
STAFFORD_PROJS  PLOCATION = ‘Stafford’(PROJECT)
CONTR_DEPT  (STAFFORD_PROJS
PROJ_DEPT_MGR  CONTR_DEPT
DNUM=DNUMBER DEPARTMENT
MGRSSN=SSN EMPLOYEE
)
)
RESULT  PNUMBER,DNUM,LNAME,ADDRESS,BDATE(PROJ_DEPT_MGR)
Sept. 2012
Yangjun Chen
ACS-3902
2
Database System - Assignment #3
(C) Retrieve the names of employees who have no dependents.
ALL_EMPS  SSN(EMPLOYEE)
EMPS_WITH_DEPS  ESSN(DEPENDENT)
EMPS_WITHOUT_DEPS  (ALL_EMPS – EMPS_WITH_DEPS)
RESULT  LNAME, FNAME(EMPS_WITHOUT_DEPS * EMPLOYEE)
Sept. 2012
Yangjun Chen
ACS-3902
3
Database System - Assignment #3
2. (30) Exercise 7.18 on Page 235
Specify the following queries on the database schema shown in Figure 7.5,
using the relational operators defined in the relational algebra. Also show the
result of each query as it would apply to the database of Figure 7.6. (Using the
figures available on my home page).
a. Retrieve the name of all employees in department 5 who work more than
10 hours per week on the ‘Product X’ 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.
e. Retrieve the names of all employees who work on every project.
Sept. 2012
Yangjun Chen
ACS-3902
4
Database System - Assignment #3
(in third edition)
3. (20) Exercise 7.22 on Page 237
Consider the relation
CLASS(Course#, Univ_Section#, InstructorName, Semester, BuildingCode,
Room#, TimePeriod, Weekdays, CreditHours).
This represents classes taught in a university, with unique Univ_Section#. Identify
what you think should be various candidate keys, and write in your own words the
constraints under which each candidate key would be valid.
4. (20) Exercise 7.27 on Page 239
Consider the two tables T1 and T2 shown in Figure 7.21 (available on my home
page). Show the results of the following operations:
a. T1
c. T1
T1.p=T2.A
T1.P=T2.A
e. T1  T2
Sept. 2012
T2
T2
b. T1
T1.Q=T2.B
T2
d. T1
T1.Q=T2.B
T2
f. T1
(T1.P=T2.A and T1.R=T2.C)
Yangjun Chen
ACS-3902
T2
5
Download