Sitemap

ACID Properties in SQL Databases

2 min readMar 13, 2025

--

In database management, ensuring data integrity and consistency is critical. This is where ACID properties come into play. ACID stands for Atomicity, Consistency, Isolation, and Durability — four fundamental principles that guarantee reliable transactions in SQL databases.

Let’s break down each property and understand why they matter.

1. Atomicity: All or Nothing

Atomicity ensures that a transaction is either fully completed or fully rolled back if any part of it fails. This prevents partial updates that could leave the database in an inconsistent state.

Example:

Consider a bank transfer where Alice sends $500 to Bob.

BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 500 WHERE name = 'Alice';
UPDATE accounts SET balance = balance + 500 WHERE name = 'Bob';
COMMIT;

If the system crashes after deducting money from Alice but before adding it to Bob, atomicity ensures the transaction is rolled back, preventing data loss.

2. Consistency: Maintaining Valid Data

Consistency ensures that the database remains in a valid state before and after a transaction. Transactions must follow predefined rules (such as constraints, foreign keys, and triggers) to avoid corrupting data.

Example:

If a database has a constraint that prevents negative balances:

UPDATE accounts SET balance = balance - 1000 WHERE name = 'Alice';

If Alice only has $500, the transaction will be rejected to maintain consistency.

3. Isolation: Concurrent Transactions Don’t Interfere

Isolation ensures that multiple transactions executing simultaneously do not affect each other. Different isolation levels (READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE) control how transactions interact.

Example:

If two users try to book the last available ticket at the same time:

SELECT seats_available FROM tickets WHERE event_id = 123;
-- User A sees 1 seat, User B sees 1 seat
UPDATE tickets SET seats_available = seats_available - 1 WHERE event_id = 123;

Without proper isolation, both users might successfully book the same seat, leading to data inconsistency. Isolation prevents such conflicts.

4. Durability: Data is Permanent

Durability ensures that once a transaction is committed, it is permanently stored, even in case of a system crash.

Example:

If a power outage occurs right after committing a transaction:

COMMIT;

The transaction is still preserved when the system restarts, thanks to database logs and backups.

Conclusion

ACID properties are crucial for reliable and consistent database transactions.
✅ Atomicity ensures transactions fully succeed or fail.
✅ Consistency maintains valid database states.
✅ Isolation prevents transaction conflicts.
✅ Durability guarantees permanent data storage.

Get Rajesh Umrao-Data&AI’s stories in your inbox

Join Medium for free to get updates from this writer.

Understanding these principles helps database professionals design robust systems that prevent data loss, corruption, and inconsistencies.

💡 Have questions? Drop them in the comments! 🚀

--

--

Rajesh Umrao-Data&AI
Rajesh Umrao-Data&AI

Written by Rajesh Umrao-Data&AI

𝐍𝐈𝐓𝒾𝒶𝓷| Senior Analyst | Sharing my expertise in ■𝗦𝗤𝗟■𝗣𝘆𝘁𝗵𝗼𝗻 ■𝗔𝗜 & 𝗠𝗟🔗Subscribe my Youtube Channel➡️ https://www.youtube.com/@rajesh_data_ai