



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
Information about a database systems homework assignment from spring 2007, including the due date, instructions for submission, and two query execution problems. The first problem involves analyzing and comparing two query plans for joining two relations with indexes, while the second problem deals with using simple sort-merge join to join two unsorted relations. The document also includes a problem on algebraic laws and dynamic programming, as well as problems on cost estimation and failure recovery.
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Note: Print your name and NetID in the upper right corner of every page of your submission. Handin your homework to Trisha Benson in 4322 SC. In case Trisha is not in office, slide your homework under the door. To grade homeworks faster, ’The homework is partitioned into three parts. Please, submit each part separately. For each part, make sure to write down your name and NetID. This homework is partitioned into 3 parts as follows: Part 1: Problem 1 - Problem 2 Part 2: Problem 3 - Problem 4 Part 3: Problem 5 - Problem 6 There is a bonus credit of 2% if your homework is formatted correctly: Each part must be separable so that it can be independently graded. If you submit a paper copy then each part should i) be separately stapled and ii) include your netid. For I2Cs students: If you submit an electronic copy (or fax) then each part should start on a new page and include your netid at the top of each page. Handwritten submissions will be graded but they will take longer to grade. For clarity, machine formatted text is preferable: Expect to lose points if your handwritten answer is unclear or misread by the grader.
Suppose you have 2 relations, R(A, B, C) and S(B, C, D, E). You have a clustered unique (no duplicate keys) B+-tree index on attribute A for relation R. Assume this index is kept entirely in memory (i.e., you do not need to read it from disk).
For relation S, you have two indexes: (i) a non-clustered non-unique B+-tree index for attribute B, and (ii) a clustered non-unique B+-tree index for attribute C. Assume that these two indexes are also kept in memory. Also, assume that all of the tuples of S that agree on attribute C are stored in sequentially adjacent blocks on disk (that is, if more than one block is needed to store all of the tuples with some value of C, then these blocks will be sequentially located on the disk).
Other relevant data:
You want to execute the following query: SELECT * FROM R, S WHERE (R.B=S.B) AND (R.C=S.C) We present you with two query plans: Plan 1: 1: For every block BL of R, retrieved using the clustered index on A for R 2: For every tuple r of BL 3: Use the index on B for S to retrieve all of the tuples s of S such that s.B=r.B 4: For each of these tuples s, if s.C=r.C, output r.A, r.B, r.C, s.B, s.C, s.D, s.E Plan 2: 1: For every block BL of R, retrieved using the clustered index on A for R 2: For every tuple r of BL 3: Use the index on C for S to retrieve all of the tuples s of S such that s.C=r.C 4: For each of these tuples s, if s.B=r.B, output r.A, r.B, r.C, s.B, s.C, s.D, s.E
(a) Analyze the above two plans carefully in terms of their behavior regarding accesses to disk, and explain which of the plans is better. Be sure to include in your analysis which accesses to disk are sequential accesses and which ones are random accesses. (b) Suggest an alternative plan that is better than the above two in terms of disk access? You do not need to submit detail computations for this question. Briefly explain your assumptions and your alternative plan and argue why your plan is better.
Exercise 16.2.2 part b) c) d) (Page 809)
Compute the optimal plan for R ./ S ./ T ./ U using the dynamic programming algorithm, assuming the following: R (a,b,c), S(b,c,d), T(b,d,e), U(e,f) T(R) =1000, T(S) = 500, T(T) = 250, T(U) = 125 V(R,c) = V(S,c)=10, V(S, b)= V(R,b)= V(T,b)= V(S, d)= V(T,d) =20, V(T,e)=V(U,e)= The cost of a join is estimated to be the cost of the subplans plus the size of the intermediate results (the same as the cost model we have in Lecture). (a) Please draw the table for dynamic programming, to show how you compute the optimal plan for all possible join orders allowing all trees. (You only need to show columns with two or more joins) (b) Please draw the table for dynamic programming, to show how you compute the optimal plan for all possible join orders allowing left-deep trees only. (You only need to show columns with two or more joins)
Consider two relations R(a,b,c) and S(c,d,e) with the following statistics: B(R)=100; T(R) = 1000; V(R,a) = 20; V(R,b) = 10; V(R,c)= B(S)= 500; T(S)= 1500; V(S,c)=30; V(S,d)=10; V(S,e)= (a) Estimate the number of tuples in σa=10(R) (b) Estimate the number of tuples in σc=10(R) (c) Estimate the number of tuples in σ(b=10)∧(c=20)(R) (d) Estimate the number of tuples in σb< 25 (R) (e) Estimate the number of tuples in σ(b=25)∨(c>5)(R) (g) Estimate the number of tuples in R ./ S (h) Estimate the number of tuples in R ./R.c=S.c AN D R.b=S.d S
Consider the following transaction log from the start of the run of a database system that is using undo/redo logging with (Nonquiescent) Checkpointing for crash recovery.
What is the value for the data items X, Y, Z, U, V and W on disk after recovery: (a) if the system crashes just before line 13 is written to disk? (b) if the system crashes just before line 14 is written to disk? (c) if the system crashes just before line 19 is written to disk?