CSE 444 Midterm Exam (Autumn 1998) SOLUTIONS
Student (ssn, name)
Prof (ssn, name)
Course (number, instructor-ssn, title, credits, room#)
Enroll (student-ssn, course#)
Room (number, capacity)
JonesCourse#s = Project<number> [Select<name="Jones"> (Prof Join<ssn=instructor-ssn> Course)]
JonesStudents = Project<ssn> [Student Join<ssn=student-ssn> (Enroll Join<course#=number> JonesCourse#s)]
PhysicsStudents = Project<ssn> [Student Join<ssn=student-ssn> Select<title="Physics"> (Enroll Join<course#=number> Course)]
Answer = Project<name> [Student Join<ssn=ssn>(JonesStudents Intersect PhysicsStudents)]
StudentCourseRoom = Project<ssn,room#,course#> (Enroll Join<course#=number> Course)
SameRoomStudents = Project<ssn> (StudentCourseRoom Join<ssn=ssn & room#=room# & course# != course#> StudentCourseRoom)
AllStudents = Project<ssn> Student
Answer = Project<name> [Student Join<ssn=ssn>(AllStudents – SameRoomStudents)]
SELECT distinct title
FROM course
WHERE number in
(SELECT number FROM course, prof
WHERE instructor-ssn = ssn AND name = "Smith")
OR room# = 444
ORDERBY title
SELECT title, AVG(capacity)
FROM course, room
WHERE room# = room.number
AND credits = 3
AND course.number in
(SELECT number FROM course, prof
WHERE instructor-ssn = ssn and name = "Brown")
GROUP BY title
HAVING AVG(capacity) > 20
R(A,B,C,D) with FDs BC -> D, C -> A, AB -> C
Keys: AB, BC
Violations: C -> A, CD -> A
Decomposition: (B,C,D) and (C,A)