Docsity

Midterm Exam - Database Management System | COP 5725, Exams of Computer Science

Toggle sidebar
bg1
COP5725 Database Management Systems
Midterm – Fall 2005
Instructor: Alin Dobra
October 27, 2005
Name:
UFID:
Email:
•This is a 120 minute, closed-book exam. You are allowed to use handwritten notes on both
sides of a US letter size sheet of paper.
•This exam contains 9 single-sided sheets of paper (including this one)
•Write all answers on these pages, preferably on the white space in the problem statement.
Continue on the back page if running out of space but clearly number your answers if doing
so.
•Make sure you attack every problem; partial credit will be awarded for incomplete or partially
correct results.
Grading:
1 20
2 15
3 50
4 15
Total 100
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Midterm Exam - Database Management System | COP 5725 and more Exams Computer Science in PDF only on Docsity!

COP5725 Database Management Systems

Midterm – Fall 2005

Instructor: Alin Dobra

October 27, 2005

Name:

UFID:

Email:

  • This is a 120 minute, closed-book exam. You are allowed to use handwritten notes on both sides of a US letter size sheet of paper.
  • This exam contains 9 single-sided sheets of paper (including this one)
  • Write all answers on these pages, preferably on the white space in the problem statement. Continue on the back page if running out of space but clearly number your answers if doing so.
  • Make sure you attack every problem; partial credit will be awarded for incomplete or partially correct results.

Grading:

Total 100

  1. E-R Model[20]

A university registrar’s office maintains data about the following entities:

  • courses, including number, title, credits, syllabus and prerequisites
  • course offerings, including course number, year, semester, section number, instructor, timings, and classroom
  • students, including student-id, name, and program
  • instructors, including identification number, name, department, and title

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.

  1. Relational Algebra and SQL [50]

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.

  1. Database Modifications and Constraints [15]

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.