Desirable Properties of Transactions (ACID Properties)
Desirable Properties of Transactions (ACID Properties)
In database systems, transactions must satisfy a set of important properties to ensure correct, reliable, and consistent database operations.
These properties are called the ACID properties.
ACID =
-
A – Atomicity
-
C – Consistency
-
I – Isolation
-
D – Durability
These properties are enforced by concurrency control and recovery mechanisms in the DBMS.
1. Atomicity
Definition
Atomicity means “all or nothing.”
A transaction must be executed completely, or not executed at all.
If any part of the transaction fails, the DBMS must undo all its operations.
Example
Bank Transfer Transaction:
Two possible outcomes:
✔ Correct execution
✖ Incorrect partial execution
This would cause data inconsistency.
Atomicity ensures that:
Who Enforces Atomicity?
The Recovery Subsystem of the DBMS ensures atomicity.
If a failure occurs:
-
All partial updates are rolled back
-
The database returns to the previous state
2. Consistency Preservation
Definition
Consistency means:
A transaction must take the database from one consistent state to another consistent state.
A consistent state is a state where all integrity constraints are satisfied.
Example
Suppose a banking rule:
If a withdrawal transaction attempts:
The transaction must not complete, because it would violate the constraint.
Thus the database remains consistent.
Responsibility for Consistency
Consistency is ensured by:
-
Database programmers
-
Integrity constraint enforcement in the DBMS
The DBMS checks rules such as:
-
Primary key constraints
-
Foreign key constraints
-
Domain constraints
-
Business rules
3. Isolation
Definition
Isolation means that:
Each transaction should execute as if it is the only transaction running in the system.
Even though multiple transactions run concurrently, their execution should appear independent.
Why Isolation Is Needed
Without isolation, transactions may interfere with each other, causing problems such as:
-
Lost updates
-
Dirty reads
-
Incorrect summaries
-
Unrepeatable reads
Isolation prevents such interference.
Example
Two transactions updating the same bank account:
Transaction T1:
Transaction T2:
Without isolation, their operations may overlap and produce incorrect results.
With isolation, the system ensures that the final result is equivalent to serial execution.
Who Enforces Isolation?
The Concurrency Control Subsystem of the DBMS enforces isolation.
Techniques include:
-
Locking
-
Timestamp ordering
-
Multiversion concurrency control
4. Durability (Permanency)
Definition
Durability means:
Once a transaction is committed, its changes must permanently remain in the database, even if failures occur.
After commit, the updates cannot be lost.
Example
Suppose a transaction inserts a new customer record.
Even if the system crashes immediately afterward:
-
The new record must still exist in the database.
How Durability Is Achieved
Durability is ensured by the recovery subsystem using:
-
System logs
-
Database backups
-
Redo operations
The system records updates in the log file, so they can be restored after a crash.
Summary of ACID Properties
| Property | Meaning | Responsible Component |
|---|---|---|
| Atomicity | Transaction executes completely or not at all | Recovery system |
| Consistency | Database moves from one consistent state to another | Programmers + DBMS constraints |
| Isolation | Transactions execute independently | Concurrency control |
| Durability | Committed changes remain permanent | Recovery system |
Levels of Isolation
Different database systems provide different isolation levels.
| Isolation Level | Guarantees |
|---|---|
| Level 0 | Prevents overwriting dirty data |
| Level 1 | Prevents lost updates |
| Level 2 | Prevents lost updates and dirty reads |
| Level 3 (True Isolation) | Prevents lost updates, dirty reads, and unrepeatable reads |
Another commonly used approach is Snapshot Isolation, where transactions work with a snapshot of the database.
Summary
ACID properties ensure that:
-
Transactions execute correctly
-
Database remains consistent
-
Concurrent execution is safe
-
Committed data is permanent
Without ACID properties, database systems would produce unreliable and inconsistent results.
ACID properties (Atomicity, Consistency, Isolation, Durability) guarantee reliable and correct transaction execution in a DBMS.
Comments
Post a Comment