0 · Recall Warm-up
Answer from memory first. Answers are in the Answer Vault at the bottom.
- What is the cost unit used for disk-based query cost? from Lesson 5.1.1
- Which DBMS job undoes half-finished tasks after a crash? from Lesson 0.1.2
- What does "atomic" mean for a task? from Lesson 0.1.1
1 · The Hook
Asha pays ₹500 of hostel fees by bank transfer. Two updates must happen: ₹500 leaves her account, ₹500 reaches the college. If the server crashes between them, the money has left one account and reached nobody. A DBMS groups such steps into a transaction and guarantees four properties, ACID, so that this can never be seen.
2 · Predict First
The transfer is: read A; A = A − 500; write A; read B; B = B + 500; write B. The system crashes right after "write A". After restart, what should the database show for A and B?
Make a guess in your head. The answer opens Section 3.
3 · Core Concept
Predict First — the answer
The original values of both (as if the transfer never started). A transaction is all or nothing: since it did not finish, its write to A must be undone. This is atomicity, enforced by the recovery manager.
Transaction
A transaction is a sequence of database operations that forms one logical unit of work. In the abstract model only two data operations matter:
- read(X) (R(X)): copy item X from the database into a local variable;
- write(X) (W(X)): copy the local variable back into item X.
Computation on local variables (A = A − 500) is invisible to the database. A transaction ends with commit (all changes become permanent) or abort (all changes are undone, also called rollback).
ACID
| Property | Meaning | Who ensures it |
|---|---|---|
| Atomicity | All operations happen, or none do. | Recovery manager (undo using the log) |
| Consistency | A transaction run alone takes the database from one consistent state to another (e.g. A + B unchanged by a transfer). | The programmer, plus integrity constraints |
| Isolation | Concurrent transactions do not see each other's intermediate states; the result equals some serial order. | Concurrency control manager |
| Durability | Once committed, changes survive any later failure. | Recovery manager (redo using the log, stable storage) |
Transaction states
- Active: executing operations.
- Partially committed: the last operation has executed; changes may still be only in memory.
- Committed: changes are made durable (commit record safely written).
- Failed: normal execution cannot continue (error, crash, conflict).
- Aborted: rolled back to the state before it started; it may then be restarted or killed.
- Terminated: committed or aborted.
Transitions: active → partially committed → committed; active → failed; partially committed → failed; failed → aborted.
4 · Visual
Transaction states. Only a committed transaction's changes become permanent.
5 · Worked Examples
Example 1 Easy
Which ACID property is violated if a committed transfer disappears after a power cut?
Solution
Durability.
Example 2 Medium
A + B = 2000 before the transfer. During the transfer, after write(A) and before write(B), another transaction computes A + B and gets 1500. Which property failed?
Solution
Isolation: the other transaction saw an intermediate state of the transfer.
Example 3 GATE
Which ACID property is the responsibility of the application programmer rather than the DBMS?
Solution
Consistency (beyond declared constraints, only the programmer knows that a transfer must preserve A + B). Atomicity and durability are the recovery manager's; isolation is concurrency control's.
6 · GATE Traps
- Consistency is mainly the programmer's job; the other three are the DBMS's.
- Partially committed ≠ committed: a failure there still leads to abort.
- Atomicity is about one transaction's completeness; isolation is about interference between transactions.
- Local computation is not a database operation; only reads and writes count.
7 · Memory Hook
"A-C-I-D: All-or-nothing, Correct-by-design, Invisible-to-others, Durable-after-commit."
8 · Connect the Dots
9 · Self-Test
GATE format. Try every question before opening the vault.
Q1 · MCQ · 1 mark(s) — ACID
Which component ensures durability?
- (A) Application programmer
- (B) Concurrency control manager
- (C) Query optimiser
- (D) Recovery manager
Q2 · MCQ · 1 mark(s) — States
After its last operation executes but before its changes are made permanent, a transaction is:
- (A) committed
- (B) aborted
- (C) terminated
- (D) partially committed
Q3 · MSQ · 2 mark(s) — ACID
Which properties are the DBMS's responsibility (not mainly the programmer's)?
- (A) Consistency
- (B) Isolation
- (C) Atomicity
- (D) Durability
Q4 · MCQ · 1 mark(s) — Operations
In the transaction model, A = A − 500 (on a local copy) is:
- (A) not a database operation
- (B) a read operation
- (C) a commit
- (D) a write operation
Q5 · MCQ · 2 mark(s) — Atomicity
A transaction executes write(A) and then the system crashes before commit. On restart the recovery manager must:
- (A) commit the transaction
- (B) undo write(A)
- (C) leave A as it is
- (D) redo write(A)
10 · Rule Card
- Transaction = one logical unit of work: read(X), write(X), ending in commit or abort.
- Atomicity (recovery: undo), Consistency (programmer + constraints), Isolation (concurrency control), Durability (recovery: redo).
- States: active → partially committed → committed; active/partially committed → failed → aborted; committed/aborted = terminated.
11 · Concept Ledger
Unlocked in this lesson. From here on, these terms may be used.
transactionread(X)write(X)commitabort (rollback)ACIDatomicityconsistencyisolationdurabilitytransaction statesrecovery managerconcurrency control manager
12 · Answer Vault
Reveal answers when you’re ready
Recall Warm-up
- The block access.
- Recovery.
- All or nothing.
Self-Test
Q1 Answer: (D) · 1 mark(s)
Log-based redo and stable storage.
- (A) is wrong: Consistency.
- (B) is wrong: Isolation.
- (C) is wrong: Speed.
Re-read: Lesson 6.1.1 — Transaction basics: read/write, commit/abort, ACID, transaction states
Q2 Answer: (D) · 1 mark(s)
Definition.
- (A) is wrong: Not yet durable.
- (B) is wrong: No failure.
- (C) is wrong: Not finished.
Re-read: Lesson 6.1.1 — Transaction basics: read/write, commit/abort, ACID, transaction states
Q3 Answer: (B) (C) (D) · 2 mark(s)
Consistency depends on the program's logic.
- (A) is wrong: Programmer plus constraints.
Re-read: Lesson 6.1.1 — Transaction basics: read/write, commit/abort, ACID, transaction states
Q4 Answer: (A) · 1 mark(s)
Only read(X) and write(X) touch the database.
- (B) is wrong: The read came earlier.
- (C) is wrong: No.
- (D) is wrong: The write comes later.
Re-read: Lesson 6.1.1 — Transaction basics: read/write, commit/abort, ACID, transaction states
Q5 Answer: (B) · 2 mark(s)
Uncommitted work is rolled back.
- (A) is wrong: It never reached commit.
- (C) is wrong: Violates atomicity.
- (D) is wrong: Redo is for committed transactions.
Re-read: Lesson 6.1.1 — Transaction basics: read/write, commit/abort, ACID, transaction states