COMPSCI 186 Study Guide - Midterm Guide: Good Luck!!, Ibm System R, Redone
University of California, Berkeley
College of Engineering
Spring 2011 Prof. Michael J. Franklin
MIDTERM II
CS 186 Introduction to Database Systems
NAME: ____________________________ STUDENT ID:__________________
IMPORTANT: Circle the last two letters of your class account:
cs186 a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
DISCUSSION SECTION DAY & TIME:____________ TA NAME: ___________
This is a closed book examination – but you are allowed one 8.5” x 11” sheets of notes (double
sided). You should answer as many questions as possible. Partial credit will be given where
appropriate. There are 100 points in all. You should read all of the questions before starting the
exam, as some of the questions are substantially more time-consuming than others.
Write all of your answers directly on this paper. Be sure to clearly indicate your final answer
for each question. Also, be sure to state any assumptions that you are making in your answers.
GOOD LUCK!!!
Problem
Possible
Score
1. Recovery
31
2. SQL
25
3. Relational Algebra
12
4. Query Evaluation and Optimization
32
TOTAL
100
SID:____________________
CS 186 Midterm II April 7, 2011 Page 2 of 9
Question 1 – Recovery [7 parts, 31 points total]
Consider the following content of a log produced using Write-Ahead Logging. Assume that the
log contains all operations since the start of the DBMS. Note that at this point, no system crash
has occurred:
LSN
Transaction ID
Content
prevLSN
10
T1
update P5
null
20
T2
update P3
null
30
T1
update P5
10
40
T2
commit
20
Now consider four statements:
A. P5 appears in the dirty page table with recLSN 10
B. P5 appears in the dirty page table with recLSN 30
C. P5 appears in the dirty page table, but we don’t have enough information to know what
the recLSN would be.
D. None of the above
a) [3 points] Consider the state of the system during normal operation after the log record with
LSN 40 is written. If the buffer manager uses a “STEAL” / NO FORCE” policy, which one of
the above statements is guaranteed to be true? Why?
D. In steal/no-force, P5 and P3 can be flushed to disk anytime.
b) [3 points] Consider the state of the system during normal operation after the log record with
LSN 40 is written. If the buffer manager uses a “NO STEAL” / “NO FORCE” policy, which
one of the above statements is guaranteed to be true? Why?
A. In no-steal, P5 must not be flushed before T1 commits.
c) [3 points] Consider the state of the system during normal operation after the log record with
LSN 40 is written. If the buffer manager uses a “NO STEAL” / “FORCE” policy, which one of
the above statements is guaranteed to be true? Why?
A. In no-steal, P5 must not be flushed before T1 commits.
SID:____________________
CS 186 Midterm II April 7, 2011 Page 3 of 9
Question 1 – Recovery (continued)
Below is the state of the log after a system crash has occurred. Assume STEAL/NO FORCE
buffer management and that the log contains all operations since the start of the DBMS.
LSN
XactId
Content
prevLSN
10
T1
update P5
null
20
T1
update P5
10
30
T2
update P4
null
40
T3
update P1
null
50
T2
Commit
30
60
T2
End
50
70
--
begin_checkpoint
--
80
--
end checkpoint
--
90
T4
update P3
null
100
T1
update P2
20
110
T1
Abort
100
120
T4
update P4
90
130
T1
CLR: undo LSN 100, undoNextLSN = 20
110
d) [5 points] Assuming that no dirty pages were written to disk prior to the crash, What are
contents of the transaction table contained in the checkpoint ending at LSN 80?
XactID
LastLSN
Status
T1
T3
20
40
running
running
PageID
RecLSN
P1
P4
P5
40
30
10
Document Summary
Discussion section day & time:____________ ta name: ___________ This is a closed book examination but you are allowed one 8. 5 x 11 sheets of notes (double sided). You should answer as many questions as possible. You should read all of the questions before starting the exam, as some of the questions are substantially more time-consuming than others. Write all of your answers directly on this paper. Be sure to clearly indicate your final answer for each question. Also, be sure to state any assumptions that you are making in your answers. Score: recovery, sql, relational algebra, query evaluation and optimization. Question 1 recovery [7 parts, 31 points total] Consider the following content of a log produced using write-ahead logging. Assume that the log contains all operations since the start of the dbms. Note that at this point, no system crash has occurred: T2 update p5 update p3 update p5 commit.