Professional Documents
Culture Documents
University of Florida
Exam II
Name:
UFID:
The movie producers and studio presidents are all movie executives, and Movies(producerC#)
and Studio(presC#) are foreign keys referring to movieExec(cert#).
(1) [6 points] Find the producers (names) of movies in which Harrison Ford stars.
Solution:
SELECT name
FROM MovieExec, Movies, StarsIn
WHERE cert# = producerC# AND
title = movieTitle AND
year = movieYear AND
starName = ’Harrison Ford’;
(2) [6 points] For the producers who made at least one film before 1930, find their
names and the total film length they made.
Solution:
(3) [6 points] For each movie executive who is the president of a studio, attach the
title ’Pres. ’ in front of his name. (Hint: use || for string concatenation).
Solution:
UPDATE MovieExec
SET name = ’Pres. ’ || name
WHERE cert# IN (SELECT presC# FROM Studio);
Consider the B+-tree shown in the following figure. Its nodes have at most 4 keys (and
5 pointers). The subtrees A, B and C are valid B+ sub-trees. Answer the following
questions:
10 20 30 80
A B C
90 98
35 42 50 65 81 82 98 99 100 105
30 31 42 43 68 69 70 79 94 95 96 97
36 38 51 52 56 60
(3) [8 points] Show the tree after deleting key 31 and 81.
Solution: See next page.
(4) [5 points] Starting from the original tree, find a key which increases the height of
the tree when inserted.
COP5725, Fall 2013 Exam II Page 3 of 5
10 20 30 80
A B C
95 98
42 50 65 82 94 98 99 100 105
30 36 38 51 52 56 60 95 96 97
42 43 68 69 70 79
Solution: Any key in the range [53, 78] will cause a split that propagates all the way to
the root.
Solution: Clustered:
• Traverse the tree: 2 internal + 1 index = 3 block I/O’s;
• Read all data blocks with qualifying tuples (i.e., A = x);
• On avg. 15,000,000/500,000 = 30 qualifying data tuples = 6 data blocks. (1 index
block).
• Total block I/O’s: 3 + 6 = 9.
Unclustered: 3 + 30 = 33.
COP5725, Fall 2013 Exam II Page 4 of 5
(3) [13 points] Estimate the number of disk I/O’s for the following evaluation plans
for S ./ R, when M = 3 main memory buffer blocks are available:
• Plan p1: Index nested loop join using the B+ index in (1).
• Plan p2: Sort-merge-join (assume that the relations are already sorted).
Solution: Plan p1: Indexed nested loop join
• Cost = ns × c + bs = 800, 000 × 9 + 160, 000 = 7, 360, 000 block I/O’s.
Note: Do not deduct points if they get c = 9 wrong in the previous problem.
Plan p2: Merge join
• Avg. number of tuples with same A-value in s: 800, 000/500, 000 = 2;
• All tuples with the same A-value fit in memory;
• Cost = bs + br = 160,000 + 3,000,000 = 3,160,000 I/O’s.
T1 T2 T3
r2 (Z)
r2 (Y )
w2 (Y )
r3 (Y )
r3 (Z)
r1 (X)
w1 (X)
w3 (Y )
w3 (Z)
r2 (X)
r1 (Y )
w1 (Y )
w2 (X)
(1) [5 points] Draw the conflict graph of this schedule and show whether it is conflict
serializable or not.
Solution:
T1 T2
T3
The schedule is not conflict serializable since the conflict graph contains cycles.
COP5725, Fall 2013 Exam II Page 5 of 5
(2) [5 points] Write down the conflict action pairs and the type of anomalies such
conflict pairs can result in: dirty read, overwriting uncommitted data, and unre-
peatable read.