Transactions & ACID Questions with Answers

30 practice questions on Transactions & ACID (DBMS) with answers and step-by-step solutions. Try 10 samples below, then practise all 30 free in the AptiNest app.

Sample questions

Question 1Easy

In which transaction state has the last statement executed but the commit not yet completed?

  1. Failed
  2. Aborted
  3. Partially committed
  4. 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

  1. Active: the transaction is executing statements.
  2. After its final statement it becomes partially committed.
  3. 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?

  1. Durability means data can never be deleted
  2. Uncommitted changes remain visible to other transactions after a restart
  3. Durability is guaranteed by locking
  4. 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

  1. Durability promises committed changes are not lost.
  2. The DBMS ensures it by writing log records to stable storage at commit.
  3. 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

What does ROLLBACK do?

  1. Undoes all changes made by the current transaction
  2. Releases a single lock
  3. Restores the database from last night's backup
  4. 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

  1. ROLLBACK ends the current transaction unsuccessfully.
  2. The DBMS uses the log's before-images to undo every change the transaction made.
  3. 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?

  1. Atomicity
  2. Consistency
  3. Durability
  4. Isolation

Answer: A. Atomicity

Explanation

If any part fails, the whole transaction is rolled back, typically using the undo log.

Step-by-step solution

  1. A transaction must take effect fully or not at all.
  2. If it fails midway, its partial changes are rolled back.
  3. 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:

  1. Unrepeatable read
  2. Lost update
  3. Dirty read
  4. 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

  1. T2 reads T1's uncommitted value.
  2. T1 rolls back, so that value never officially existed.
  3. 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:

  1. Deadlock
  2. Phantom read
  3. Cascading rollback
  4. Two-phase commit

Answer: C. Cascading rollback

Explanation

Cascadeless schedules avoid it by letting transactions read only committed data.

Step-by-step solution

  1. Several transactions read T1's uncommitted writes.
  2. When T1 aborts, those readers must abort too, and so on.
  3. 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?

  1. Active -> Failed -> Aborted
  2. Failed -> Active -> Aborted
  3. Active -> Committed -> Failed
  4. 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

  1. A transaction starts in Active.
  2. On an error it moves to Failed.
  3. 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?

  1. After a majority of participants vote YES
  2. Only after every participant has voted YES
  3. Before sending PREPARE, if all logs are flushed
  4. 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

  1. Phase 1: the coordinator sends PREPARE and collects votes.
  2. Commit needs a YES from every participant.
  3. 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?

  1. Stay blocked until it learns the global decision
  2. Abort locally after a timeout
  3. Elect itself as the new coordinator and broadcast a global commit decision
  4. 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

  1. After voting YES, the participant has promised to commit if told to.
  2. It cannot abort alone, because others may have committed, and cannot commit alone, because others may have aborted.
  3. 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?

  1. Phantom reads only
  2. Dirty reads and phantom reads
  3. Non-repeatable reads only
  4. 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

  1. REPEATABLE READ blocks dirty reads.
  2. It also blocks non-repeatable reads.
  3. 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 →

Related topics

See all DBMS topics · All topics