Skip to content

Latest commit

 

History

History
92 lines (58 loc) · 3.34 KB

File metadata and controls

92 lines (58 loc) · 3.34 KB

💥 ACID Properties in DBMS

Definition (1-liner to start your answer):

ACID stands for Atomicity, Consistency, Isolation, and Durability — these are the key properties that ensure a transaction in a database is reliable, even in case of failures.


🧩 1️⃣ Atomicity — “All or Nothing”

Meaning: A transaction is atomic — it either completes fully or doesn’t happen at all.

Example: When transferring ₹1000 from Account A to B:

  • Step 1: Deduct ₹1000 from A
  • Step 2: Add ₹1000 to B

If Step 2 fails, Step 1 must roll back so money doesn’t disappear.

Interview tip: ✅ “Atomicity ensures that partial transactions don’t leave the database in an inconsistent state.”


⚖️ 2️⃣ Consistency — “Valid before and after”

Meaning: The database must remain valid before and after the transaction. All constraints, rules, and relationships must still hold true.

Example: If a constraint says account balance cannot go negative, the DB should reject any transaction violating this.

Interview tip: ✅ “Consistency ensures that only valid data following all constraints is written to the database.”


🔒 3️⃣ Isolation — “No interference between transactions”

Meaning: Multiple transactions can occur at the same time without affecting each other’s results.

Example: Two users booking movie tickets — each transaction should see a consistent view of the seats and not double-book.

Interview tip: ✅ “Isolation prevents one transaction’s intermediate data from being visible to another.”

(If interviewer asks further:)

  • SQL supports isolation levels like READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE.

💾 4️⃣ Durability — “Once done, it stays done”

Meaning: After a transaction is successfully committed, its changes are permanent — even if the system crashes immediately after.

Example: If a transfer succeeds and then the server crashes, the new balance should still be there when it restarts.

Interview tip: ✅ “Durability guarantees that committed data is safely stored on disk and cannot be lost.”


🧠 Quick Summary Table

Property Keyword Meaning
Atomicity All or nothing Entire transaction succeeds or fails
Consistency Validity Database remains correct
Isolation Independence Transactions don’t affect each other
Durability Permanence Committed data won’t be lost

💬 How to Say It in an Interview (sample answer)

“ACID stands for Atomicity, Consistency, Isolation, and Durability. Atomicity ensures a transaction happens completely or not at all. Consistency maintains database validity before and after a transaction. Isolation ensures transactions running simultaneously don’t affect each other’s results. And Durability means once a transaction is committed, the data remains safe even after system failures. Together, these properties make database transactions reliable.”

Would you like me to give you a few short practice questions interviewers ask about ACID (like scenario-based ones)?