ACID Properties
The four pillars of reliable database transactions
The four pillars of reliable database transactions This hands-on tutorial focuses on practical implementation of acid properties concepts.
What are ACID Properties?
To ensure data integrity, relational databases follow the ACID model.
1. Atomicity (A)
"All or Nothing"
A transaction is treated as a single unit. It either completes entirely or fails entirely.
- Example: In a money transfer, if the deduction happens but the addition fails, the deduction is rolled back.
2. Consistency (C)
"Rules are Followed"
A transaction must bring the database from one valid state to another valid state, maintaining all constraints (Unique, Foreign Key, etc.).
- Example: You cannot insert a row that violates a
PRIMARY KEYconstraint, even inside a transaction.
3. Isolation (I)
"Independent Execution"
Transactions executed concurrently should create the same state as if they were executed sequentially.
- One transaction should not see the intermediate (uncommitted) results of another transaction (depending on Isolation Level).
Isolation Levels
- Read Uncommitted: Lowest isolation, can see dirty data.
- Read Committed: Standard for many DBs.
- Repeatable Read: Ensures if you read a row twice, you get the same data.
- Serializable: Highest isolation, strictly sequential.
4. Durability (D)
"Saved Forever"
Once a transaction is committed, it remains committed even in the case of a system failure (power loss, crash). Use of transaction logs ensures this.
Identify the Property
Problem Statement
Which ACID property ensures that a transaction is saved permanently once committed, even if the system crashes immediately after?