asg3

pdf

School

McMaster University *

*We aren’t endorsed by this school

Course

3DB3

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

3

Uploaded by ryankum007

Report
McMaster University SFWRENG 3DB3, Fall 2023 Assignment 3 Due: Dec. 1, 2023 at 10:00pm November 23, 2023 I. Database Design (65 marks) Question 1 (12 marks) Keys Consider a relation schema R ( A, B, C, D, E ) , and the set of functional dependencies F = { A BC CD E B D E A } Find all candidate keys (i.e., minimal keys) of relation R . Show all the steps you took to derive each key, and clearly state which of Armstrong’s axioms are used in each step. Question 2 (8 marks) Decomposition Consider the relation R(A,B,C,D,E), and the decomposition of R into R1(ABC) and R2(ADE). (a) (4 marks) Give a set of functional dependencies (FDs) such that the decomposition into R1 and R2 is lossless join and dependency preserving. Show your work and explain why your FDs satisfy the criteria. (b) (4 marks) Give a set of functional dependencies such that the decomposition into R1 and R2 is not lossless join, but dependency preserving. Show your work and explain why your FDs satisfy the criteria. Question 3 (35 marks) Functional Dependencies, BCNF The Department has a database containing information about all lectures during a term. The Schedule relation has the following schema: 1
Schedule ( C, D, T, R, P, A ) where C represents a course, D for day (weekday), T for time, R for room, P for professor, and A for head TA. The set of functional dependencies F defined over Schedule are: F = { RDT P, RDT C, C A, PDT R, PDT C, CDT P, CDT R } Answer the following questions: (a) (4 marks) Is the FD RDT AP entailed by F ? Explain and show your work with references to Armstrong’s axioms. (b) (6 marks) Find all the key(s) of relation Schedule . Show your work (i.e., how each key is derived). (c) (6 marks) Is Schedule in BCNF? If not, decompose it into smaller relations that are each in BCNF. Show your work at each step. (d) (6 marks) We can create a new relation ProfsSchedule ( D, T, P ) by projecting some at- tributes of Schedule . Are there new functional dependencies that hold over ProfsSchedule ? If so, state these FDs. If not, state why not. In both cases, show your work at each step to justify your answer. (e) (13 marks) Find a minimal cover F min for F . Show all the steps in your derivation of F min . Question 4 (10 marks) Armstrong’s Axioms Prove the following using Armstrong’s axioms (using only the axioms presented in class). Show all the steps of your proof, and indicate which of Armstrong’s axioms is applied in each step. a) (5 marks) Consider the schema R(A,B,C,D,E,F), and the following functional dependencies: A BCD, BC DE, B D, D A . Show that AF is a superkey. b) (5 marks) Given the relational schema R ( A, B, C, D, E, F ) and the FDs F 1 : { AB C , A D , CD EF } . Show that AB F . II. Transactions and Concurrency (30 marks) Question 5 (6 marks) Schedules I Consider schedules S 1 , S 2 below. State which of the following properties hold (or not) for each schedule: strict, avoids cascading aborts, recoverability. Provide a brief justification for each answer. (a) (3 marks) S 1 : R 1 ( X ); R 2 ( Z ); R 1 ( Z ); R 3 ( X ); R 3 ( Y ); W 1 ( X ); C 1 ; W 3 ( Y ); C 3 ; R 2 ( Y ); W 2 ( Z ); W 2 ( Y ); C 2 (b) (3 marks) S 2 : R 1 ( X ); R 2 ( Z ); R 3 ( X ); R 1 ( Z ); R 2 ( Y ); R 3 ( Y ); W 1 ( X ); W 2 ( Z ); W 3 ( Y ); W 2 ( Y ); C 3 ; C 1 ; C 2 2
Question 6 (18 marks) Schedules II (a) (8 marks) Consider the schedules S 1 and S 2 given below. Draw the serializability (precedence) graphs for S 1 and S 2 and state whether each schedule is serializable or not. Provide justifi- cation to explain your answer. If a schedule is serializable, write down the equivalent serial schedule(s), i.e., ( T 2 , T 1 , T 3 ), where T i includes all actions for transaction i . (i) S 1 : R 1 ( X ); R 2 ( Z ); R 1 ( X ); R 3 ( X ); R 3 ( Y ); W 1 ( X ); W 3 ( Y ); R 2 ( Y ); W 2 ( Z ); W 2 ( Y ) (ii) S 2 : R 1 ( X ); R 2 ( Z ); R 3 ( X ); R 1 ( Z ); R 2 ( Y ); R 3 ( Y ); W 1 ( X ); W 2 ( Z ); W 3 ( Y ); W 2 ( Y ) (b) (10 marks) Consider schedules S 3 , S 4 below. If a commit or abort is not shown, assume that commit/abort must follow all the listed actions of that transaction (not necessarily immedi- ately). For simplicity, we assume the listed transactions are the only ones active currently in the database. State which of the following properties hold (or not) for each schedule: conflict serializable, avoids cascading aborts, recoverability, 2PL. If you cannot determine whether a schedule satisfies a property, state “Undetermined”. Provide a brief justification for each of your answers, for each property. (i) S 3 : R 1 ( X ) , R 1 ( Y ) , W 1 ( Y ) , R 2 ( Y ) , Commit 2 , W 3 ( Y ) , W 3 ( Z ) , W 1 ( Z ) , Commit 1 , Commit 3 (ii) S 4 : W 1 ( Y ) , R 2 ( Y ) , R 1 ( X ) , R 2 ( X ) Question 7 (6 marks) Locking Consider the following locking protocol: Before a transaction T writes a data object A, T has to obtain an exclusive lock on A. For a transaction T, we hold these exclusive locks until the end of the transac- tion. If a transaction T reads a data object A, no lock on A is obtained. State which of the following properties are ensured by this locking protocol: serializability, conflict-serializability, recoverability, avoids cascading aborts, avoids deadlock. Justify your answer for each property. Grading This assignment is worth 14% towards your final grade. Submission All files are to be submitted via Avenue. Please ensure your answers are typed and clearly readable. Non-typed solutions will not be marked and receive a mark of zero. Include your name and student ID number in the file. Submit your solutions to all questions in a file called asg3.pdf . 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help