Complete Exam-Style Questions with Detailed Rationales |
100% Verified | Pass Guaranteed – A+ Graded
Section A: Transaction Management & Recovery
Q1: A banking transaction transfers $500 from Account A to Account B. The system
crashes after debiting Account A but before crediting Account B. Upon recovery, the
database must restore Account A to its original balance. Which ACID property ensures
this restoration occurs?
A. Consistency, ensuring the total money in the system remains unchanged
B. Isolation, preventing other transactions from seeing the partial debit
C. Atomicity, ensuring either all operations complete or none do, rolling back partial
changes [CORRECT]
D. Durability, guaranteeing the debit is permanently recorded
Correct Answer: C
Rationale: Atomicity requires that a transaction's operations are treated as a single
indivisible unit—either all complete successfully or all are rolled back. Consistency
preserves database constraints, isolation prevents interference, and durability ensures
committed changes survive failures. Only atomicity mandates rollback of partial
updates.
Q2: A database system uses write-ahead logging (WAL) for recovery. Which rule MUST
be enforced to ensure correct recovery after a crash?
A. Data blocks must be written to disk before any log records are written
B. Log records must be written to stable storage before the corresponding data blocks
are written to disk [CORRECT]
C. Checkpoints must be taken after every transaction commits
D. Undo operations must be performed before redo operations during recovery
,Correct Answer: B
Rationale: The WAL protocol requires that all log records for a modification be written to
stable storage before the modified data page is written to disk. This ensures that if a
crash occurs, the log contains sufficient information to redo or undo operations. Writing
data before logs would make recovery impossible for unlogged changes.
Q3: During system recovery, the recovery manager encounters a transaction in the log
with a <start, T> record but no <commit, T> or <abort, T> record. What action must the
recovery manager take for this transaction?
A. Redo all its operations because it may have committed before the crash
B. Undo all its operations because it did not complete before the crash [CORRECT]
C. Ignore the transaction because it has no effect on database consistency
D. Restart the transaction automatically from the beginning
Correct Answer: B
Rationale: A transaction with a start record but no commit/abort record was active at
the time of the crash. According to recovery protocols (immediate update with logging),
all operations of such transactions must be undone to restore the database to a
consistent state. Redo is only for transactions that have committed but whose changes
may not be on disk.
Q4: A database administrator configures the isolation level to READ COMMITTED for a
reporting application. Which anomaly is PREVENTED at this level but ALLOWED in READ
UNCOMMITTED?
A. Phantom reads
B. Non-repeatable reads
C. Dirty reads [CORRECT]
D. Lost updates
Correct Answer: C
Rationale: READ COMMITTED prevents dirty reads (reading uncommitted data) by
ensuring transactions only see committed changes. READ UNCOMMITTED allows dirty
, reads. Non-repeatable reads and phantom reads are still possible in READ COMMITTED.
Lost updates require higher isolation or explicit locking to prevent.
Q5: A system implements deferred modification (deferred update) for transaction
recovery. Which statement accurately describes this technique?
A. Updates are written to the database immediately and logged for possible undo
B. Updates are buffered in memory and written to the database only after the
transaction commits [CORRECT]
C. Updates are written to shadow copies of pages and the shadow copy becomes
permanent immediately
D. Updates are written to the log but never to the database, requiring complete
reconstruction on restart
Correct Answer: B
Rationale: Deferred update (NO-UNDO/REDO) buffers all updates in memory and applies
them to the database only after commit. This eliminates the need for undo during
recovery but requires redo if committed changes were not written to disk before a crash.
Immediate update requires both undo and redo capabilities.
Q6: A transaction T1 is in the "partially committed" state. Which event would transition it
to the "committed" state?
A. The transaction begins execution of its first operation
B. The final operation has executed successfully and the commit log record has been
written to stable storage [CORRECT]
C. The transaction encounters a division-by-zero error during execution
D. The recovery manager initiates a rollback due to deadlock
Correct Answer: B
Rationale: A transaction enters the partially committed state after its final operation
executes but before the commit record is written to stable storage. It transitions to
committed once the commit record is successfully written to the log on stable storage.
Active is the initial state, failed occurs on error, and aborted follows rollback.