

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
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.
Suppose we want to join two relations R and S on attribute A, and then project the resulting tuples on A. (Thus, we do not worry about other attributes.) The values of A in the relations, listed in the order of relation scanning, are as follows:
R.A : 5 , 2 , 4 , 1 , 7 , 2 , 3 , 8 S.A : 4 , 7 , 5 , 2 , 9 , 8
Let’s execute the join with different algorithms below. For each algorithm, show the resulting tuples (which have only one attribute A) in the order that they are produced.
(a) Index join using an index on R.A.
(b) Sort-merge join.
Exercise 15.5.5 (Page 756)
(a) Starting with an expression πL(R(a, b, c) ./ S(b, c, d, e)), push the projection down as far as it can go if L is b + c → x, d + e → y.
(b) Starting with an expression πL(R(a, b, c) ./ S(b, c, d, e)), push the projection down as far as it can go if L is a, b, a + d → z.
(c) Starting with an expression πL(R(a, b, c) ./R.b>S.d S(b, c, d, e)), push the projection down as far as it can go if L is a, d.
Consider the join of relations R(a, b), S(b, c), T (c, d), and U(a, d), where R and S each have 250 tuples, while T and U each have 2000 tuples. Further, there are 375 values of all attributes of all relations, except for attribute b, where V (R, b) = V (S, b) = 20.
(a) What is the order selected by the greedy algorithm? What is its cost?
(b) Give the dynamic-programming table entries that evaluates all possible join orders al- lowing all trees. And show what the best choice is.
(c) Give the dynamic-programming table entries that evaluates all possible join orders al- lowing left-deep trees only. And show what the best choice is.
Estimate the size of the join R(a, b)onS(b, c) using histograms for R.b and s.b. Assume V (R, b) = V (S, b) = 25, and the histograms for both attributes give the frequency of the five most common values, as tabulated below:
0 1 2 3 4 5 others R.b 4 7 6 5 3 35 S.b 9 7 8 5 6 40
How does this estimate compare with the simpler estimate, assuming that all 25 values are equally likely to occur, with T (R) = 60 and T (S) = 75?
Exercise 17.1.2 (Page 883)
Consider a database with data items {A, B, C, D}. The system uses an undo/redo scheme and has the following logs. Note that an entry 〈T, X, old, new〉 means transaction T changes the value of X from old to new.
We will consider recovery using this udno/redo log. Suppose that the database, at the point when the system failed, is A=a, B=b, C=c, and D=d (where a, b, c, and d are some values).
(a) What are the initial values of A, B, C, and D, before all the transactions start?
(b) List all the possible values of a, b, c, and d. That is, what are the possible data values on the disk at the point of failure (i.e., right after action 21)? Explain why. (Hint: This problem essentially asks you to think how “dirty data” might be buffered in memory or flushed to disks.)
(c) During recovery, how far back in the log do we have to scan to? Answer in terms of Action ID. Explain why.
(d) During recovery, what are the transactions that need to be undone?
(e) During recovery, what are the transactions that need to be redone?
(f) What are the values of A, B, C, and D after recovery? Explain why.