





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






A university registrar’s office maintains data about the following entities:
Further, the enrolment of students in classes and grades awarded to students in each course they are enrolled for must be appropriately modeled.
a. [15] Construct an E-R diagram for the registrar’s office. Document all assumptions you make about the mapping constraints. Use the back of the page if you need more space.
b. [5] Decompose the relation so that it is in BCNF, or justify why it cannot be decomposed.
c. [5] Suppose we remove the last functional dependency (i.e. E → A). Decompose the relation so that it is in BCNF, or justify why it cannot be decomposed.
Consider the following relational schema:
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)
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. Managers are not employees of any department.
Write the following queries in relational algebra:
a. [5] Print the name and the age of each employee who works in both Hardware and Software departments.
b. [5] For each employee, print the names of all its managers.
c. [5] For each manager that is at most 40 years old, print its name and its salary.
Write the following queries in SQL:
a. [5] Print the name and the age of each employee who works in both Hardware and Software departments.
b. [5] Print the name and the number of departments each employee works in.
c. [5] 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.
d. [5] Find the ename of the manager who manages the department with the largest budget.
e. [5] Find the ename of managers who manage only departments with budgets larger than $1 million, but at least one department with budget less than $5 million.
Consider the schema in the previous problem. To define constraints, you have to give the SQL code that specifies both the schema and the constraints.