← Previous: T08.11: Lossless-Join Decomposition and Dependency Preservation | 🏠 Index | Next: T09.2: The Consistency Property in Depth →
T09.1: ACID Properties of Transactions
Topic: T09 — Transactions, ACID & Anomalies | Priority: 🔴 High Priority | Exam Frequency: 5/7 finals + CT-04 Q1 (18 final marks + 6 CT marks = 24 marks total)
Sources: Silberschatz 7e Ch. 17 (§17.1–§17.2, pp. 799–804) · Lecture Deck 07 (Slides 3–7) · Raidah Class Notes (pp. 25–26)
Why This Topic Matters
ACID properties are the foundation of database transaction management and one of the most frequently tested topics in ECE 2215, appearing in 5 out of 7 semester finals plus Class Test 4. Exam questions ask for both crisp definitions and the exact DBMS subsystem that enforces each property. You will also regularly be asked to trace a bank transfer transaction step by step, explain what goes wrong when any of the four properties is missing, or sketch a state-evolution diagram.
📝 Key Definitions
Transaction: A transaction is a logical unit of program execution that reads and updates one or more database items. It starts with begin transaction and ends with end transaction (commit or abort). It acts as a single indivisible operation that moves the database from one consistent state to another.
Atomicity: Atomicity guarantees that either all operations of a transaction take effect in the database or none of them do. If a transaction fails partway through, the recovery system uses undo logs to roll back all partial changes.
Consistency: Consistency guarantees that running a transaction by itself on a valid database leaves the database in a valid state. All declared integrity constraints and real-world business rules must still hold after the transaction finishes. It is enforced by the application programmer and the DBMS integrity subsystem.
Isolation: Isolation guarantees that concurrent transactions run without interfering with each other. Every transaction sees a database state as if all transactions ran one after another in serial order. The concurrency-control system enforces this by hiding uncommitted changes from other transactions.
Durability: Durability guarantees that once a transaction commits, all of its changes stay saved in the database permanently. Even if a power outage or system crash happens right after commit, the recovery system restores the changes from redo logs on stable storage.
The Four ACID Properties Explained
Think of a transaction as a single business task (like sending money or booking a train ticket) that takes several SQL reads and writes under the hood. To keep your data safe even when the power goes out or hundreds of users click at the same time, every relational DBMS enforces four guarantees known as ACID:
1. Atomicity ("All-or-Nothing")
A transaction usually involves multiple read and write steps. Atomicity guarantees that either every single step finishes and takes effect, or none of them do. If a transaction is cut off halfway through, the database undoes everything it did so far, leaving the data as if the transaction never started.
- Threat / Failure Mode: A power outage, OS crash, network drop, or software error right in the middle of a transaction (for example, after money is deducted from one account, but before it is added to the other).
- Enforcing Subsystem: The Recovery System.
- Mechanism: Before changing any data page on disk, the DBMS writes an undo log record using Write-Ahead Logging (WAL). If the transaction crashes midway, the recovery manager reads the undo log and rolls back every partial change.
2. Consistency (Preservation of Rules and Invariants)
Suppose the database starts in a valid state where all table constraints and real-world business rules hold true. Consistency guarantees that running a transaction from start to finish on its own leaves the database in another valid state where all those rules still hold.
- Threat / Failure Mode: Buggy application code or invalid user input (for example, a bug that deducts $50 from the sender but adds $100 to the receiver).
- Enforcing Subsystem: The Application Programmer (who must write bug-free business logic) together with the DBMS Integrity Subsystem (which checks
PRIMARY KEY, FOREIGN KEY, and CHECK constraints).
- Mechanism: The DBMS blocks any statement that breaks schema constraints, while the developer makes sure the program preserves business invariants (like keeping the total money before and after a transfer equal).
3. Isolation (Shielding Concurrent Transactions)
In a real system, dozens of transactions run at the same time. Isolation guarantees that running transactions concurrently produces the exact same result as running them one by one in a strict line (serially). Any half-finished, uncommitted changes made by one transaction stay completely invisible to other transactions until it commits.
- Threat / Failure Mode: Concurrency bugs like dirty reads, lost updates, or unrepeatable reads when two transactions interleave their reads and writes on the same row.
- Enforcing Subsystem: The Concurrency-Control System.
- Mechanism: Enforced using locking protocols (such as Two-Phase Locking, 2PL), Timestamp Ordering (TSO), or Multi-Version Concurrency Control (MVCC).
4. Durability (Permanent Survival After Commit)
Once a transaction finishes all its steps and the DBMS confirms commit, its changes are permanent. Even if the server loses power one millisecond after the commit message is sent, the committed data will never be lost.
- Threat / Failure Mode: A power blackout or OS crash right after the user sees "Payment Successful," while the updated pages are still sitting in volatile RAM.
- Enforcing Subsystem: The Recovery System.
- Mechanism: Before confirming a
commit, the DBMS flushes redo log records to non-volatile disk or SSD storage. When the server reboots after a crash, the recovery manager replays those redo logs to restore every committed change.
Summary of ACID Properties and Enforcing Components
| Property | Core Guarantee | Typical Threat Mitigated | Enforcing Component |
|---|
| Atomicity | All operations take effect or none do | Mid-execution hardware failure or crash | Recovery System (Undo Log) |
| Consistency | Invariants and schema constraints hold | Flawed program logic or invalid inputs | Programmer Logic + DBMS Constraints |
| Isolation | Intermediate states hidden from other transactions | Interleaved concurrent execution conflicts | Concurrency-Control System (2PL/TSO) |
| Durability | Committed data persists permanently | System crash immediately after commit | Recovery System (Redo Log on Stable Storage) |
Intuitive Mini-Example: How ACID Works Together
Before looking at the full Silberschatz $50 bank transfer problem in the Golden Questions below, let's trace a quick 4-line mobile wallet transfer of BDT 200 from Wallet X (initially BDT 500) to Wallet Y (initially BDT 300):
- Consistency checks that total wallet money stays BDT 500+300=BDT 800 both before (500 + 300) and after (300 + 500) the transfer.
- Atomicity protects you if the server crashes right after X drops to BDT 300 (before Y gets the BDT 200) by rolling X back to BDT 500.
- Isolation stops a second transaction from peeking during that middle moment when X=300 and Y=300 (which temporarily sums to BDT 600).
- Durability guarantees that once the app shows "Transfer Complete," the new balances (X=300,Y=500) are safely logged on disk even if the server room loses power a second later.
Figure 9.1: State evolution diagram for a fund transfer transaction (tested in 2018 Q.4b below).
Exam Variants
The table below summarizes all past semester final and class test questions on ACID properties:
| Year & Question | Marks | Format / Focus | Key Elements Expected in Solution |
|---|
| 2017 Q.5(a) | 4 | Definition and brief discussion | 1-mark concise description per property, naming the enforcing subsystems. |
| 2018 Q.4(b) | 4 | Description with appropriate diagram | Structured explanation + $50 transfer diagram showing state evolution. |
| 2021 Q.7(a) | 4 | Detailed explanation | Full explanation of each property with failure prevention roles. |
| 2023 Q.4(b) | 4 | Importance with suitable example | Justify why each property is essential and show concrete failure consequences. |
| 2024 Q.6(c) | 2 | Concise discussion | Fast, calibrated 0.5-mark bullet points per property. |
| CT-04 Q.01 | 6 | Definition of transaction + 4 properties | Formal transaction definition (1.5m) + detailed ACID discussion (4.5m). |
🏆 Golden Questions (Past Exam Archive)
🎯 GQ1 · 2017 Q.5(a) · ACID Properties Discussion
Appeared: 2017 Q.5(a) [also 2021 Q.7(a), 2024 Q.6(c)] — (4 marks)
Question:
Briefly discuss the ACID properties of transaction.
Full Answer:
A transaction is a logical unit of program execution that accesses and possibly updates various data items in a database. Delimited between begin transaction and end transaction, a transaction must preserve database integrity despite hardware crashes and concurrent users. To guarantee correctness, the DBMS enforces the four ACID properties:
-
Atomicity ("All-or-None"):
- Meaning: Either all operations of the transaction are properly reflected in the database, or none are.
- Operational Rule: If a failure occurs before the transaction finishes, all partial updates made so far are rolled back.
- Enforced by: The Recovery System using write-ahead undo log records.
-
Consistency (Preservation of Invariants):
- Meaning: Execution of a transaction in isolation preserves database consistency. The database transitions from one valid state satisfying all integrity rules to another valid state.
- Operational Rule: Total assets and domain constraints remain intact across the execution.
- Enforced by: The Application Programmer (correct business logic) and the DBMS Integrity Constraint Subsystem (primary keys, foreign keys,
CHECK constraints).
-
Isolation (Shielding Concurrent Access):
- Meaning: Even though multiple transactions execute concurrently, the system guarantees that each transaction is unaware of other concurrently executing transactions.
- Operational Rule: Intermediate, uncommitted updates remain completely hidden from concurrent transactions.
- Enforced by: The Concurrency-Control System using locking mechanisms (such as 2PL) or timestamp protocols.
-
Durability (Persistence):
- Meaning: After a transaction completes successfully and commits, all changes made to the database persist permanently, even if system crashes or power failures happen right afterward.
- Operational Rule: Committed data is saved to non-volatile stable storage before the commit call confirms.
- Enforced by: The Recovery System using write-ahead redo logs.
(Calibrated note for 2-mark variant in 2024 Q.6(c): Write one clear sentence for each property mentioning its primary guarantee and enforcing subsystem.)
🎯 GQ2 · 2018 Q.4(b) · ACID Properties with Diagram
Appeared: 2018 Q.4(b) — (4 marks)
Question:
Describe the ACID-properties of database system with appropriate diagram.
Full Answer:
To ensure data reliability against system crashes and concurrent interleaved execution, every database transaction must satisfy the four ACID properties: Atomicity, Consistency, Isolation, and Durability.
Illustration: Bank Fund Transfer (T1)
Consider accounts A and B with initial balances of $1000 and $2000, respectively. Transaction T1 transfers $50 from account A to account B:
1.2.3.4.5.6.7.read(A)A:=A−50write(A)[A becomes 950]read(B)B:=B+50write(B)[B becomes 2050]commit
Illustrative Diagram
Figure 9.2: ACID properties in fund transfer transaction.
Description of Properties Mapped to the Diagram
- Atomicity: If the system crashes after step 3, account A is 950 while account B remains 2000. Without atomicity, $50 is lost. The recovery system uses undo log records to roll back A to 1000, ensuring all-or-none execution.
- Consistency: The business invariant is A+B=3000. The initial state (1000+2000=3000) and the final state (950+2050=3000) both satisfy this rule. Money is neither created nor destroyed.
- Isolation: Between steps 3 and 6, the intermediate total is temporarily 950+2000=2950. The concurrency control system blocks concurrent transaction T2 from reading this intermediate state. T2 sees either pre-transfer balances or post-transfer balances.
- Durability: After step 7 commits, balances A=950 and B=2050 are recorded to stable storage. The updates survive immediate power loss or operating system reboot.
🎯 GQ3 · 2021 Q.7(a) · Detailed Explanation of ACID Properties
Appeared: 2021 Q.7(a) — (4 marks)
Question:
Explain the ACID properties of transaction.
Full Answer:
A transaction is a logical unit of database processing that includes one or more database access operations. Delimited by begin transaction and commit/abort, transactions must maintain database integrity under all operating conditions.
The four ACID properties provide complete protection:
-
Atomicity:
- Concept: Guarantees all-or-nothing execution.
- Protection: Prevents incomplete transactions from leaving partial updates in the database. If any operation within the transaction fails or the operating system halts, the recovery manager aborts the transaction and reverses all partial modifications using undo logs.
-
Consistency:
- Concept: Guarantees preservation of database validity and invariants.
- Protection: Moves the database from one valid state satisfying all integrity constraints (primary keys, foreign keys, domain checks) and application invariants to another valid state. The application programmer guarantees correct arithmetic logic, while the DBMS validates constraints.
-
Isolation:
- Concept: Shields concurrently executing transactions from one another.
- Protection: Ensures that concurrent transactions execute as if they were running sequentially. Intermediate uncommitted modifications are hidden from other transactions, preventing anomalies such as dirty reads or lost updates. Enforced by locking schemes or timestamp ordering.
-
Durability:
- Concept: Guarantees permanence of committed updates.
- Protection: Ensures that once a transaction completes successfully and receives a commit confirmation, its modifications persist permanently in non-volatile storage. Even if a complete power failure occurs immediately afterward, the database re-creates the updates using redo logs during crash recovery.
🎯 GQ4 · 2023 Q.4(b) · Importance of ACID Properties with Example
Appeared: 2023 Q.4(b) — (4 marks)
Question:
Briefly explain the importance of ACID properties of transactions with suitable example.
Full Answer:
Databases support multi-user environments and mission-critical financial applications. The ACID properties are essential because without them, hardware failures and concurrent access would inevitably corrupt data and produce catastrophic business errors.
Concrete Scenario
Consider a banking system where customer A holds $1000 and customer B holds $2000. The business invariant requires total funds to remain constant: A+B=3000. Transaction T1 transfers $50 from A to B.
Importance of Each Property and Failure Consequences
-
Importance of Atomicity:
- Disaster without Atomicity: Suppose the database server loses power right after deducting $50 from account A, before adding $50 to account B. Account A is 950, while account B is 2000. Customer A lost $50, but customer B never received it.
- Importance: Atomicity requires the recovery system to undo the deduction, restoring A back to 1000 so that no customer funds disappear.
-
Importance of Consistency:
- Disaster without Consistency: Suppose a flawed transaction program debits $50 from A but credits $100 to B. The final total becomes 950+2100=3050. The bank creates $50 out of thin air.
- Importance: Consistency ensures transaction logic satisfies mathematical invariants (A+B=3000), preserving the accuracy of real-world financial records.
-
Importance of Isolation:
- Disaster without Isolation: Between the debit to A and the credit to B, the intermediate total is temporarily 950+2000=2950. If an automated audit transaction T2 runs concurrently and reads account balances during this window, it detects an apparent $50 discrepancy and raises a false regulatory alarm.
- Importance: Isolation hides uncommitted intermediate states. T2 is forced to read data either completely before T1 (total 3000) or completely after T1 (total 3000).
-
Importance of Durability:
- Disaster without Durability: Transaction T1 finishes, prints a successful transfer receipt for the customer, and terminates. Two seconds later, the server experiences a power outage while the updates are still sitting in volatile RAM cache. Upon reboot, the database reverts to the old balances, wiping out the confirmed transfer.
- Importance: Durability guarantees that committed data is written to non-volatile stable log storage before confirmation, ensuring customer transactions survive power outages.
🎯 GQ5 · 2024 Q.6(c) · Concise Discussion of ACID Properties
Appeared: 2024 Q.6(c) — (2 marks)
Question:
Briefly discuss the ACID properties of transaction.
Full Answer:
A transaction is a logical unit of database work. To preserve data integrity during system failures and concurrent execution, the DBMS ensures four ACID properties:
- Atomicity ("All-or-None"): All operations of the transaction take effect in the database or none do. If a crash interrupts execution, partial changes are rolled back by the recovery system using undo logs.
- Consistency: Execution in isolation preserves database validity. If the database starts in a consistent state satisfying all integrity constraints and business invariants, it ends in a consistent state.
- Isolation: Each transaction executes unaware of other concurrent transactions. Intermediate uncommitted modifications remain hidden from concurrent transactions, enforced by the concurrency-control system.
- Durability: Once a transaction commits successfully, its updates persist permanently on non-volatile stable storage, surviving any later power outages and system crashes.
🎯 GQ6 · CT-04 Q.01 · Definition and Detailed Explanation
Appeared: CT-04 Q.01 — (6 marks)
Question:
Define a transaction? Explain the four ACID properties of a transaction with suitable examples.
Full Answer:
1. Definition of a Transaction
A transaction is a logical unit of program execution that accesses and possibly updates various data items in a database. It is initiated by an application program and delimited by statements of the form begin transaction and end transaction (commit or abort). To the database user, a transaction appears as a single indivisible operation that transforms the database from one consistent state to another.
2. The Four ACID Properties with Examples
Consider transaction T1 transferring $50 from account A (initially $1000) to account B (initially $2000):
T1:read(A)→A:=A−50→write(A)→read(B)→B:=B+50→write(B)→commit
-
Atomicity:
- Explanation: All operations in the transaction must be properly reflected in the database, or none are.
- Example: If the database crashes after executing write(A), account A has 950 while account B still has 2000. Atomicity requires the recovery system to undo the update on A, restoring its balance to 1000.
- Enforcement: Recovery system using write-ahead undo logging.
-
Consistency:
- Explanation: A transaction executed in isolation must preserve database consistency, satisfying all explicit constraints and implicit invariants.
- Example: The business invariant requires total funds A+B=3000. Before execution, A+B=1000+2000=3000. After completion, A+B=950+2050=3000.
- Enforcement: Application programmer logic supported by DBMS integrity constraints (
PRIMARY KEY, FOREIGN KEY, CHECK).
-
Isolation:
- Explanation: Even when multiple transactions execute concurrently, each transaction must execute without interference. Intermediate uncommitted states remain invisible to other transactions.
- Example: After step 3, A=950 and B=2000. If another transaction T2 runs concurrently to calculate total assets (A+B), isolation prevents T2 from reading the intermediate sum 2950. T2 reads either 3000 before T1 runs or 3000 after T1 completes.
- Enforcement: Concurrency-control system using two-phase locking (2PL) or timestamp protocols.
-
Durability:
- Explanation: Once a transaction completes successfully and commits, all of its updates persist permanently and cannot be lost due to future crashes.
- Example: Once T1 executes
commit at step 7, updates A=950 and B=2050 are recorded to stable disk storage. If the server loses power a moment later, the values remain intact upon reboot.
- Enforcement: Recovery system using redo log records written to stable storage.
📖 High-Yield Exercises from the Book
🎯 HYE-01 · Exercise 17.12 · Architectural Usefulness and Trade-Offs of Relaxing ACID Guarantees
Source: Silberschatz 7e · Chapter 17 (Exercise 17.12)
Exam Relevance: High-Probability Advanced Systems & Trade-Off Drill
Key Tested Concept: Deep architectural usefulness of ACID properties, workload-specific trade-offs (read-only OLAP vs write-heavy OLTP), and system implications of relaxing Atomicity versus Isolation.
Problem Statement:
Silberschatz Exercise 17.12 requires listing the ACID properties and explaining the usefulness of each. Beyond elementary definitions, analyze the architectural trade-offs when these guarantees are relaxed:
- Explain the specific engineering usefulness of Atomicity and Isolation in database management systems.
- Evaluate how the necessity of Atomicity and Isolation differs fundamentally between read-only analytical workloads and write-heavy OLTP workloads.
- Provide a comparative trade-off matrix analyzing what happens to system throughput, latency, and data consistency when Atomicity versus Isolation is relaxed.
Model Exam-Style Solution:
-
Architectural Usefulness of Atomicity and Isolation:
- Atomicity (All-or-Nothing Execution):
- Usefulness: Shields applications from partial state corruption caused by process crashes, power outages, network partitions, or transaction aborts. Without atomicity, an application would have to manually detect where a failure happened and write custom compensation routines for every possible failure point. Atomicity shifts this burden entirely to the DBMS recovery system (via Write-Ahead Logging and rollback).
- Isolation (Concurrency Shield):
- Usefulness: Allows application developers to write transaction code under the simplifying assumption that each transaction executes sequentially in complete solitude. The concurrency control manager automatically interleaves operations across thousands of concurrent sessions to maximize hardware utilization while preventing race conditions, dirty reads, and lost updates.
-
Workload-Specific Analysis: Read-Only (OLAP) vs. Write-Heavy (OLTP):
- Read-Only / Analytical Workloads (OLAP):
- Atomicity: Trivially satisfied. Because read-only transactions execute only read(Q) instructions and perform no database modifications (write(Q)), there are no partial state changes to undo upon a crash or abort. Atomicity incurs zero recovery overhead.
- Isolation Trade-Off: Full serializability requires setting shared locks (S-locks) or maintaining multi-version snapshot copies. For analytical queries scanning millions of tuples (e.g., aggregate sales calculations), holding read locks causes severe lock contention, blocking write transactions across the entire system. Consequently, database administrators frequently relax isolation to Read Committed or Read Uncommitted (dirty reads), accepting approximate or slightly stale data in exchange for massive throughput gains and zero lock blocking on concurrent writers.
- Write-Heavy Transactional Workloads (OLTP):
- Atomicity: Strictly non-negotiable. In multi-step updates (e.g., transferring $50 between accounts, processing inventory alongside order billing), any partial execution violates core business invariants. An un-rolled-back debit of $50 without the corresponding credit permanently destroys capital. The DBMS must enforce strict WAL logging and undo capabilities.
- Isolation Trade-Off: Enforcing strict conflict serializability (e.g., via Strict 2PL) forces write-heavy transactions to acquire exclusive locks (X-locks) and hold them until commit. This leads to high lock queuing, transaction wait times, and frequent deadlocks. To maximize OLTP transaction throughput, modern production engines relax isolation from
SERIALIZABLE to READ COMMITTED or Snapshot Isolation (SI). This allows readers to read consistent snapshots without blocking writers, while write-write conflicts are handled via row-level locks, balancing high concurrency with data integrity.
-
Comparative Trade-Off Matrix: Relaxing Atomicity vs. Isolation:
| Dimension | Relaxing Atomicity | Relaxing Isolation (e.g., Read Committed / Snapshot) |
|---|
| Enforcing Subsystem | Recovery Manager (WAL / Undo Log) | Concurrency-Control Manager (2PL / Locks / MVCC) |
| Safe in Read-Only Workloads? | Yes (Trivially Safe): No write operations occur; rollback is never required. | Yes (Widely Practiced): Analytical queries can tolerate slightly stale data without blocking active writers. |
| Safe in Write-Heavy Workloads? | No (Catastrophic): Leaves partial modifications in persistent storage, corrupting invariants permanently. | Conditionally Safe: Used standardly across industry (Oracle, PostgreSQL default to Read Committed / SI) to eliminate read locks. |
| System Performance Gain | Negligible in normal operation; eliminating undo logs saves small disk I/O, but system corruption risks are fatal. | Huge: Drastically reduces lock contention, eliminates read-write lock waits, and increases transaction throughput tenfold. |
| Resulting Data Anomalies | Orphaned records, vanished assets, broken referential integrity. | Non-repeatable reads, phantom tuples, and write skew (preventable via row locks or validation). ■ |
💡 RUET Exam Takeaway:
Never confuse the scope of the two: Atomicity protects against internal/system failures (must never be relaxed for updates), whereas Isolation manages multi-user concurrency (frequently relaxed to lower isolation levels in industry to scale throughput).
⚡ Exam Tips & Common Mistakes
- Name the Enforcing Component: Examiners specifically look for the database subsystem responsible for each property. Always state: Atomicity → Recovery System (undo log), Consistency → Application Programmer + DBMS Constraints, Isolation → Concurrency-Control System, and Durability → Recovery System (redo log on stable storage).
- Do Not Confuse Atomicity and Isolation: Atomicity deals with failure and rollback (what happens when a transaction crashes midway). Isolation deals with concurrency (what concurrent transactions are allowed to observe while execution is underway).
- Remember Programmer Responsibility for Consistency: A common student mistake is asserting that the DBMS guarantees consistency automatically. If application code erroneously debits $50 and credits $500, the DBMS executes valid SQL statements, but business consistency is destroyed. The application programmer is primarily responsible for consistent logic.
- Always Use Concrete Numerical Balances: In fund transfer examples, explicitly state A=1000,B=2000, and the invariant A+B=3000. Show the intermediate state (950, 2000, sum 2950) to make the explanation undeniable.
- Draw the Evolution Diagram for 4-Mark Questions: When a question says "with appropriate diagram" (like 2018 Q.4(b)), draw the three state boxes (Initial, Intermediate, Final) and connect them with arrows indicating the ACID guarantees.
🔗 Related Topics
← Previous: T08.11: Lossless-Join Decomposition and Dependency Preservation | 🏠 Index | Next: T09.2: The Consistency Property in Depth →