Sample questions
Question 1Easy
In which transaction state has the last statement executed but the commit not yet completed?
- Failed
- Aborted
- Partially committed
- Active
Answer: C. Partially committed
Explanation
From partially committed the transaction moves to committed once its log records reach stable storage.
Step-by-step solution
- Active: the transaction is executing statements.
- After its final statement it becomes partially committed.
- Once its commit record reaches stable storage it is committed; if something fails, it moves to failed and then aborted.
Why the other options are wrong
- A. Failed means normal execution cannot continue.
- B. Aborted means the transaction has been rolled back.
- D. Active means statements are still running.
Tip: Last statement done but not yet durable means partially committed.
Question 2Easy
Which statement about the durability property is correct?
- Durability means data can never be deleted
- Uncommitted changes remain visible to other transactions after a restart
- Durability is guaranteed by locking
- Committed changes survive crashes because they are recorded in stable storage
Answer: D. Committed changes survive crashes because they are recorded in stable storage
Explanation
The DBMS forces log records to non-volatile storage at commit, so after a crash it can redo committed work.
Step-by-step solution
- Durability promises committed changes are not lost.
- The DBMS ensures it by writing log records to stable storage at commit.
- After a crash, redo replays them.
Why the other options are wrong
- A. Data can still be deleted by later transactions.
- B. Uncommitted changes are undone at restart.
- C. Locking provides isolation, not durability.
Tip: Durability = log forced to disk at commit.
Question 3Easy
- Undoes all changes made by the current transaction
- Releases a single lock
- Restores the database from last night's backup
- Saves all changes permanently
Answer: A. Undoes all changes made by the current transaction
Explanation
ROLLBACK returns the database to the state before the transaction began (or to a savepoint).
Step-by-step solution
- ROLLBACK ends the current transaction unsuccessfully.
- The DBMS uses the log's before-images to undo every change the transaction made.
- The database returns to its state before the transaction began (or to a savepoint, if one is named).
Why the other options are wrong
- B. Locks are released as a result, but undoing changes is the purpose.
- C. Restoring a backup is a separate media-recovery task.
- D. That is COMMIT.
Tip: COMMIT keeps the changes; ROLLBACK discards them.
Question 4Easy
Which ACID property ensures that a transaction is executed completely or not at all?
- Atomicity
- Consistency
- Durability
- Isolation
Answer: A. Atomicity
Explanation
If any part fails, the whole transaction is rolled back, typically using the undo log.
Step-by-step solution
- A transaction must take effect fully or not at all.
- If it fails midway, its partial changes are rolled back.
- This all-or-nothing property is atomicity.
Why the other options are wrong
- B. Consistency is about moving from one valid state to another.
- C. Durability is about committed changes surviving crashes.
- D. Isolation is about concurrent transactions not interfering.
Tip: Atomicity = all or nothing.
Question 5Medium
T1 updates a row and T2 reads the new value before T1 commits. T1 then rolls back. T2 has performed a:
- Unrepeatable read
- Lost update
- Dirty read
- Phantom read
Answer: C. Dirty read
Explanation
Reading data written by an uncommitted transaction is a dirty (uncommitted) read; the value T2 used never officially existed.
Step-by-step solution
- T2 reads T1's uncommitted value.
- T1 rolls back, so that value never officially existed.
- Reading uncommitted data is a dirty read.
Why the other options are wrong
- A. An unrepeatable read re-reads committed changes.
- B. No write is overwritten.
- D. Phantoms are about new rows in a range.
Tip: Read before the writer commits = dirty read.
Question 6Medium
One transaction's abort forces several other transactions that read its uncommitted data to abort as well. This is called:
- Deadlock
- Phantom read
- Cascading rollback
- Two-phase commit
Answer: C. Cascading rollback
Explanation
Cascadeless schedules avoid it by letting transactions read only committed data.
Step-by-step solution
- Several transactions read T1's uncommitted writes.
- When T1 aborts, those readers must abort too, and so on.
- This chain is a cascading rollback.
Why the other options are wrong
- A. Deadlock is transactions waiting on each other's locks.
- B. A phantom read is new rows appearing in a repeated query.
- D. Two-phase commit is a distributed commit protocol.
Tip: Read only committed data and cascades cannot happen.
Question 7Medium
Which sequence of transaction states is valid for a transaction that fails midway?
- Active -> Failed -> Aborted
- Failed -> Active -> Aborted
- Active -> Committed -> Failed
- Active -> Partially committed -> Aborted -> Committed
Answer: A. Active -> Failed -> Aborted
Explanation
On an error the transaction moves from active (or partially committed) to failed, and after rollback it enters the aborted state; it can never leave committed.
Step-by-step solution
- A transaction starts in Active.
- On an error it moves to Failed.
- After rollback it is Aborted.
Why the other options are wrong
- B. Every transaction starts in Active, not Failed.
- C. A committed transaction cannot then fail.
- D. An aborted transaction never becomes committed.
Tip: Failure path: Active -> Failed -> Aborted.
Question 8Medium
In two-phase commit, when may the coordinator decide to COMMIT?
- After a majority of participants vote YES
- Only after every participant has voted YES
- Before sending PREPARE, if all logs are flushed
- As soon as the first participant votes YES
Answer: B. Only after every participant has voted YES
Explanation
2PC requires unanimous YES votes; a single NO vote or timeout leads to a global abort.
Step-by-step solution
- Phase 1: the coordinator sends PREPARE and collects votes.
- Commit needs a YES from every participant.
- Any NO or timeout means global ABORT.
Why the other options are wrong
- A. 2PC needs unanimity, not a majority.
- C. Votes are collected only after PREPARE.
- D. Other participants could still vote NO.
Tip: 2PC commit = unanimous YES.
Question 9Hard
In two-phase commit, a participant has voted YES and then loses contact with the coordinator. What must it do?
- Stay blocked until it learns the global decision
- Abort locally after a timeout
- Elect itself as the new coordinator and broadcast a global commit decision
- Commit locally after a timeout
Answer: A. Stay blocked until it learns the global decision
Explanation
After voting YES the participant is in the uncertain (prepared) state; deciding alone could contradict the coordinator, which is the blocking weakness of 2PC.
Step-by-step solution
- After voting YES, the participant has promised to commit if told to.
- It cannot abort alone, because others may have committed, and cannot commit alone, because others may have aborted.
- It must stay blocked until it learns the decision.
Why the other options are wrong
- B. The coordinator may already have decided COMMIT.
- C. Basic 2PC has no election, and the global decision is unknown.
- D. The coordinator may have decided ABORT.
Tip: Voted YES = in doubt = wait.
Question 10Hard
Which anomalies does the REPEATABLE READ isolation level still allow, according to the SQL standard?
- Phantom reads only
- Dirty reads and phantom reads
- Non-repeatable reads only
- No anomalies at all
Answer: A. Phantom reads only
Explanation
The standard defines REPEATABLE READ as preventing dirty and non-repeatable reads but still allowing phantoms; SERIALIZABLE prevents all three.
Step-by-step solution
- REPEATABLE READ blocks dirty reads.
- It also blocks non-repeatable reads.
- The standard still allows phantom reads.
Why the other options are wrong
- B. Dirty reads are blocked from READ COMMITTED upward.
- C. Non-repeatable reads are exactly what this level prevents.
- D. Only SERIALIZABLE removes phantoms.
Tip: RR: only phantoms remain.
Practise all 30 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →