ACID Properties
ACID is an acronym that stands for Atomicity, Consistency, Isolation, and Durability. These are a set of properties of database transactions that are essential for guaranteeing data validity and reliability, especially in systems like banking, e-commerce, and finance.

To understand these properties, let's use a Example: a simple bank transfer.
The Scenario
Imagine Alice wants to transfer $100 from her Savings account to her Checking account.
- Initial Savings Balance: $500
- Initial Checking Balance: $200
This single transaction requires two separate operations:
- Debit: Subtract $100 from the Savings account.
- Credit: Add $100 to the Checking account.
Here is how each ACID property ensures this transaction happens correctly.
1. Atomicity (All or Nothing)
What it means: The entire transaction must be treated as a single, indivisible "atom" of work. Either both operations (the debit and the credit) succeed, or neither of them do. There is no middle ground.
The Problem Without Atomicity: What if the system successfully debits 400), but then a power failure occurs before it can credit the $100 to her Checking account?
- Savings Balance: $400
- Checking Balance: $200
- Result: $100 has vanished into thin air. The bank's records are now incorrect.
How Atomicity Solves It: An ACID-compliant database guarantees that if a transaction is interrupted for any reason, it will be automatically rolled back. The system will undo the initial debit from the Savings account, restoring it to $500. From the database's perspective, the transaction never happened, ensuring that money is never lost or created.
2. Consistency (Data Stays Valid)
What it means: A transaction must bring the database from one valid state to another. Any data written to the database must be valid according to all defined rules, including constraints, cascades, and triggers.
The Problem Without Consistency: A fundamental rule in our banking system is that a transfer should not change the total amount of money, it should only move it.
- Valid Initial State: Total money = 200 (Checking) = $700.
- Invalid State: In the failed transaction scenario above, the total money would become 200 = $600. This state violates the bank's rules.
How Consistency Solves It: The database enforces consistency. The transaction that would result in an invalid state (like the $600 total) is not allowed to be completed. Consistency ensures that the final state of our successful transaction is also valid:
- Valid Final State: Savings = 300. Total money = 300 = $700.
3. Isolation (Transactions Don't Interfere)
What it means: Multiple transactions occurring at the same time should not interfere with each other. The result of concurrent transactions should be the same as if they were executed one after another in some sequential order.
The Problem Without Isolation: Imagine that at the exact moment Alice is making her transfer, the bank is running an automated process to calculate the total interest on all of her funds.
- The transfer starts: 400).
- The interest calculation process runs now. It reads the Savings balance (200, because the credit hasn't happened yet). It calculates interest based on a total of $600, which is wrong.
- The transfer completes: 300).
How Isolation Solves It: An ACID-compliant database will "isolate" the two transactions. It ensures that the interest calculation process will see the database either entirely before Alice's transfer began (totaling 700). It will never see the inconsistent, intermediate state, thus preventing calculation errors.
4. Durability (Once It's Saved, It Stays Saved)
What it means: Once a transaction has been successfully committed, it is permanent and will survive any subsequent system failure, such as a power outage or crash.
The Problem Without Durability: Alice's transfer completes, and she gets a "Success" notification. Her new balances are Savings: 300. Immediately after, the database server crashes.
- When the server reboots, the memory of the transaction might be lost, and her balances could revert to their original state (Savings: 200).
How Durability Solves It: An ACID-compliant database guarantees that as soon as a transaction is committed, its result is written to non-volatile storage (like a hard drive or SSD) in a transaction log. If the system crashes and reboots, it will check this log and ensure that all committed changes are restored, guaranteeing that Alice's transfer is permanent.