Step 14
8 min read

ACID Properties

Learn what ACID means - the 4 rules that keep your database safe and reliable.

What is ACID?

ACID Properties Explained
PropertySimple MeaningReal Example
AtomicityAll or nothingBank transfer: both succeed or both fail
ConsistencyFollow all rulesAge must be 0-100, enforced always
IsolationNo interferenceTwo people booking: only one gets seat
DurabilityPermanent saveData saved even if power fails
4 rows

ACID stands for 4 important rules that keep your database safe:

  • Atomicity
  • Consistency
  • Isolation
  • Durability

Simple analogy: Like safety rules for handling money at a bank.

A - Atomicity (All or Nothing)

ACID Properties Explained
PropertySimple MeaningReal Example
AtomicityAll or nothingBank transfer: both succeed or both fail
ConsistencyFollow all rulesAge must be 0-100, enforced always
IsolationNo interferenceTwo people booking: only one gets seat
DurabilityPermanent saveData saved even if power fails
4 rows

Simple meaning: Either everything happens, or nothing happens. No halfway.

Real-life example: Bank transfer

  • Subtract $100 from your account
  • Add $100 to friend's account

If step 2 fails, step 1 must be undone. You cannot lose $100!

In SQL:

BEGIN; UPDATE accounts SET balance = balance - 100 WHERE user_id = 1; UPDATE accounts SET balance = balance + 100 WHERE user_id = 2; COMMIT;

If any UPDATE fails, both are cancelled. No money lost!

C - Consistency (Follow the Rules)

ACID Properties Explained
PropertySimple MeaningReal Example
AtomicityAll or nothingBank transfer: both succeed or both fail
ConsistencyFollow all rulesAge must be 0-100, enforced always
IsolationNo interferenceTwo people booking: only one gets seat
DurabilityPermanent saveData saved even if power fails
4 rows

Simple meaning: Data must follow all rules (constraints).

Real-life example: Age must be positive

  • Cannot insert age = -5
  • Cannot insert age = 200
  • Database checks rules and rejects bad data

In SQL:

CREATE TABLE students ( age INTEGER CHECK (age > 0 AND age < 100) ); INSERT INTO students (age) VALUES (-5); -- REJECTED

Database enforces rules always.

I - Isolation (No Interference)

ACID Properties Explained
PropertySimple MeaningReal Example
AtomicityAll or nothingBank transfer: both succeed or both fail
ConsistencyFollow all rulesAge must be 0-100, enforced always
IsolationNo interferenceTwo people booking: only one gets seat
DurabilityPermanent saveData saved even if power fails
4 rows

Simple meaning: Multiple people can use database at same time without interfering.

Real-life example: Two people buying last concert ticket

  • Person A checks: 1 ticket available
  • Person B checks: 1 ticket available
  • Only one should get it!

Database ensures they do not interfere with each other.

In SQL: Database handles this automatically. Two users running queries do not mess up each other's data.

D - Durability (Data is Permanent)

ACID Properties Explained
PropertySimple MeaningReal Example
AtomicityAll or nothingBank transfer: both succeed or both fail
ConsistencyFollow all rulesAge must be 0-100, enforced always
IsolationNo interferenceTwo people booking: only one gets seat
DurabilityPermanent saveData saved even if power fails
4 rows

Simple meaning: Once saved, data stays saved forever (even if power goes off).

Real-life example: After you hit "Save" on your document

  • Even if computer crashes
  • Even if power goes out
  • Your saved data is still there

In SQL:

INSERT INTO orders (customer, total) VALUES ('John', 100); COMMIT; -- Even if server crashes now, this order is saved!

Summary with Simple Examples

ACID Properties Explained
PropertySimple MeaningReal Example
AtomicityAll or nothingBank transfer: both succeed or both fail
ConsistencyFollow all rulesAge must be 0-100, enforced always
IsolationNo interferenceTwo people booking: only one gets seat
DurabilityPermanent saveData saved even if power fails
4 rows

Atomicity: All or nothing

  • Transfer money: Both steps complete or both cancel

Consistency: Follow rules always

  • Age between 0-100: Database checks every time

Isolation: No interference

  • Two people booking same seat: Only one succeeds

Durability: Data stays saved

  • After COMMIT: Data is permanent

Why ACID Matters

ACID Properties Explained
PropertySimple MeaningReal Example
AtomicityAll or nothingBank transfer: both succeed or both fail
ConsistencyFollow all rulesAge must be 0-100, enforced always
IsolationNo interferenceTwo people booking: only one gets seat
DurabilityPermanent saveData saved even if power fails
4 rows

ACID protects your data like:

  • Seatbelt in a car (keeps you safe)
  • Lock on your door (protects your home)
  • Backup of your photos (keeps them safe)

Without ACID:

  • Money could disappear
  • Data could get corrupted
  • Multiple users could conflict

Summary

ACID Properties Explained
PropertySimple MeaningReal Example
AtomicityAll or nothingBank transfer: both succeed or both fail
ConsistencyFollow all rulesAge must be 0-100, enforced always
IsolationNo interferenceTwo people booking: only one gets seat
DurabilityPermanent saveData saved even if power fails
4 rows

ACID = 4 safety rules

  • A: All or nothing
  • C: Follow rules
  • I: No interference
  • D: Permanent storage

These rules make databases reliable and trustworthy!

Finished this topic?

Mark it complete to track your progress and maintain your streak!

SkillsetMaster - AI, Web Development & Data Analytics Courses