JIT Department of Computer Science PhD Qualifying Exam on CS 63: DATA MAAGEMET SYSTEMS DESIG Summer 202 o book or other document is allowed. Duration of the exam: 2.5 hours. The total number of points is 00.
QUESTIO [8 points] Map the following ER schema into a relational schema. A B C D E F ET4 M R ET3 P O M L K G ET5 R3 ET R2 ET2 H J I Specify: (a) relation schemas, (b) primary keys, (c) foreign keys. QUESTIO 2 [6 points] Consider the following relational schema of a University database. PREREQUISITE Prerequisite_umber COURSE Cours_ame Credit_Hours Department SECTIO Section_Identifier Semester Year Instructor GRADE_REPORT Student_umber Section_Identifier Grade STUDET ame Student_umber Class Major Primary key attributes are underlined. Thus, Student_umber and Section_Identifier together form the primary key for GRADE_REPORT. Foreign keys are shown with arrows. For instance, SECTIO. is a foreign key that refers to the primary key COURSE.. 2
Write the following queries in Relational Algebra:. Retrieve the student identifiers, names and majors of all students who do not have any grade of A in any of their courses. 2. Find the names of all the students who have taken a Computer Science course (Department = CS) and an Information Systems course (Department = IS ). 3. Find the names of all the students who have taken two distinct course sections (you are not allowed to use the grouping and aggregation operator). 4. Find the names of the students who have taken exactly (no more and no less) the course sections the students named Smith have taken. QUESTIO 3 [28 points] Consider the database schema of Question 2. Write the following queries in SQL.. Retrieve the student identifiers, names and majors of all straight A students (students who have a grade of A in all their courses). 2. Retrieve the student identifiers, names and majors of all students who do not have any grade of A in any of their courses. 3. For each section taught by Professor Smith after 2005, retrieve the section identifier, the course name, semester, year, and the average grade in this section but only for sections with less than 20 students. 4. For every section that has more than 20 Computer Science students (Major = CS ) find the section identifier, course number and total number of students it has. 5. Find the Student_umber and ame of all the students who got the same number of As in their courses as the student with Student_umber 234578 got. 6. Find the names of all the students who have not taken any of the course sections the student(s) named Smith have taken. 7. Find the names of the students who have taken exactly (no more and no less) the course sections the students named Smith have taken. QUESTIO 4 [8 points] Write SQL to enforce the following constraints. If a constraint cannot be expressed in SQL explain why.. o course can have more than three prerequisite courses. 2. The number of distinct Computer Science courses (Department = CS ) a Computer Science student (Major = CS ) can take should be at least twice as many as the number of Information Systems courses (Department = IS ). 3
QUESTIO 5 [30 points] (Please justify your answers. Answers without justification will not get any points!). Consider the relation EGS (EMPLOYEE, GRADE, SALARY) with the functional dependencies: E G, G S (a) Show that E S holds. (b) Explain why the relation is not in BCF. (c) Consider three decompositions of EGS into (i) EG (EMPLOYEE, GRADE) and GS (GRADE, SALARY) (ii) ES (EMPLOYEE, SALARY) and EG (EMPLOYEE, GRADE) (iii) ES (EMPLOYEE, SALARY) and GS (GRADE, SALARY) For each of the three decompositions listed above, answer the following three questions. You have to prove your answers. Is the decomposition lossless join decomposition? Are the resulting small relations in BCF? Are dependencies preserved? 2. Prove or disprove the following inference rules for functional dependencies. A proof can be made either by a proof argument or by using Armstrong s inference rules including reflexive rule, augmentation rule and transitive rule. A disproof should be performed by demonstrating a relation instance that satisfies the conditions and functional dependencies in the left-hand side of the inference rule but does not satisfy the dependencies in the right-hand side. a. {X Y, Y Z} = {XY Z} b. {XY Z, X Z} = {Y Z} c. {X YZ, Z WY} = {X YZW} d. {X YW} = {Y X} e. {XY Z} = {X Z} 4
QUESTIO 6 [0 points] (Please justify your answers. Answers without justification will not get any points!). Consider the schedules S given below: S : r (X); r 2 (Z); r 3 (X); r (U); r 2 (V); r 3 (Y); w (X); w 2 (Z); w 3 (U); w 2 (Y) Draw the serializability (precedence) graph for S, and state whether the schedule is serializable or not. If it is serializable, write down the equivalent serial schedule. 2. Suppose you are told that no two transactions in a set of transactions will deadlock if they are the only transactions running concurrently using two phase locking. For example, T: w(x) w(y) and T2: w(y) w(z) will never deadlock together. Call such a set pairwise deadlock-free. Consider a pairwise deadlock-free set having at least three transactions. Can such a set encounter deadlock when it executes? Either prove that the set can t encounter deadlock or show by example that it can. 5