What is ACID?
ACID properties (Atomicity, Consistency, Isolation, Durability) ensure reliable database transactions.
ACID is a set of properties that guarantee reliable database transactions. It's like the rules of a bank transfer: either the money moves completely and correctly, or it doesn't move at all. No partial transfers, no lost money.
ACID Properties:
- Atomicity: All or nothing — transaction either completes fully or doesn't happen
- Consistency: Database stays in a valid state — rules are never violated
- Isolation: Concurrent transactions don't interfere — like separate checkout lanes
- Durability: Once committed, changes are permanent — survives crashes
Why ACID Matters:
- Data integrity: Prevents corruption and inconsistencies
- Reliability: Critical operations succeed or fail completely
- Concurrency: Multiple users can work simultaneously safely
- Recovery: System can recover from failures correctly
Real-World Example - Money Transfer:
- Debit account A by $100
- Credit account B by $100
Without ACID: Account A debited but B not credited = lost money! With ACID: Both happen together or neither happens = safe!
FAQ
Do all databases support ACID?
Relational databases (SQL) typically support ACID. Many NoSQL databases sacrifice ACID for performance and scalability, though some support it.
Is ACID always necessary?
For financial data, yes. For some use cases (like social media likes), eventual consistency might be acceptable.