








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Main points of this past exam are: Maximally Efficient Protocol, Appropriate Quadrant, Recovery Protocol, Special-Purpose, After-Image, Buffer Manager, Transaction Table, Dirty Page Table, Dependencies, Violate
Typology: Exams
1 / 14
This page cannot be seen from the preview
Don't miss anything!
College of Engineering Department of EECS, Computer Science Division CS186 J. Hellerstein Spring 2003 Final Exam
This exam has seven problems, each worth a different amount of points. Each problem is made up of multiple questions. You should read through the exam quickly and plan your time-management accordingly. Before beginning to answer a question, be sure to read it carefully and to answer all parts of every question! Please do not spend time explaining your answers unless we explicitly ask that you do so. We will not be giving extra or partial credit for explanations unless we ask for them. Good luck! You must write your answers on the exam. You also must write your name at the top of every page , and you must turn in all the pages of the exam. Do not remove pages from the stapled exam! Extra answer space is provided in case you run out of space while answering. If you run out of space, be sure to make a “forward reference” to the page number where your answer continues. Do not write in this space Class Account ____________________________
e. Suppose we decompose R into the following tables: R1 = (B, C, E) R2 = (B, C, F) R3 = (B, C, D) and R4 = (A, B, C). This decomposed schema is indeed in BCNF (you can trust us on this!) Unfortunately, this decomposition is not dependency-preserving; in particular, the dependency E->F cannot be checked on a single table. A CHECK ASSERTION can be used to enforce E->F. Complete the following SQL statement for this particular CHECK ASSERTION needed to guarantee E->F. [8 points] CREATE ASSERTION checkDep CHECK ( NOT EXISTS ( SELECT * FROM R1, R WHERE _______________________ GROUP BY _____________________ HAVING COUNT(__________________________)__________)) f. Why might the ASSERTION in (e) be expensive? [2 points] i. Updates to R1 and R2 are frequent ii. Inserts to R1 and R2 are frequent iii. Insertions to R2 are frequent; R1 rarely changes. iv. Reads to R1 and R2 are frequent v. (i) and (ii) vi. (i), (ii), (iii) vii. All of the above Answer (choose one ): ___________
b. The database is still running very slowly even after you recommended the right indexes in part (a)! A careful workload study reveals that in practice, the following two transactions are extremely frequent (far more than any other queries or updates):
5. Query Optimization [15 points] Consider the following relational schema and SQL query: Student (SID, DID, Enroll_Year, Nationality) Department (DID, Name, Building_Num, Telephone, FID) Finance (FID, Budget, Expenses, …) SELECT D.Name, F.Budget FROM Student S, Department D, Finance F WHERE S.DID = D.DID and D.FID = F.FID AND D.Building_Num > 5 AND D.Building_Num <=10 AND S.Enroll_Year = 2000 OR S.Enroll_Year = 2001; Here are some statistics: — Building Numbers range from 1 to 20 inclusive (i.e. 1 and 20 are both valid numbers). — Each building has the same number of departments — Students’ enrollment year (Student.Enroll_Year) ranges from 1997 to 2002, and is distributed according to the following table: 1997 1998 1999 2000 2001 2002 5000 1400 2000 3000 7000 1600 — Number of Tuples (pages) per relation: - Student: 20000 (2000 pages) - Department: 100 (10 pages) - Finance: 100 (10 pages) (continued)
6. Concurrency control [16 points] a) Consider the following modified definition of serializability: A schedule S is serializable iff it produces the same database state as a serial schedule T, where the transactions in T are exactly those in S, and are ordered in T according to their first appearance in S. Is this definition: [3 points] i. Correct? ii. Overly restrictive: i.e. there are some serializable schedules not covered by this definition? iii. Overly permissive: i.e. there are some unserializable schedules that are covered by this definition? iv. (ii) and (iii) Answer (choose one ): ___________ b) Bob and Anne share a bank account for their business. Today they went to the bank at the same time. Draw the dependency graph for the schedule below. You do not need to label any edges in the graph. [3 points] T_Bob T_Anne Description Action Description Action Looks at checking balance
Looks at savings balance
Looks at checking balance
Transfer $ from checking to savings
Withdraw $ from checking
commit commit
c) Is the schedule in (b) conflict serializable? If so, give an equivalent serial schedule. If not, enumerate all the serial schedules, and explain how Bob and Anne’s experience would be changed in each. [5 points] d) Suppose that the database system at the bank implemented strict 2-phase locking as we studied in class. Assume that Bob and Anne’s requests for actions arrive in the same order as in (b), but if either of them is blocked while waiting for a lock, their actions stop arriving until they acquire the lock (after which time they continue as fast as they can). Describe what happens in that scenario: a few words should suffice. [5 points]