ACID Properties in DBMS: Atomicity, Consistency, Isolation, and Durability

ACID is a set of four properties that guarantee reliable processing of database transactions, even in the event of errors, power failures, or concurrent access by multiple users.

The Four ACID Properties

  • Atomicity — a transaction is treated as a single indivisible unit; it either completes fully or not at all. If any part fails, the entire transaction is rolled back.
  • Consistency — a transaction takes the database from one valid state to another, ensuring all rules, constraints, and triggers are respected.
  • Isolation — concurrent transactions execute as though they were run one after another, preventing them from interfering with each other's intermediate results.
  • Durability — once a transaction is committed, its changes are permanently saved, even if the system crashes immediately afterward.

Real-World Example: Bank Transfer

Imagine transferring ₹5,000 from Account A to Account B. This involves two steps: debit A, then credit B.

ACID PropertyRole in This Transaction
AtomicityIf the credit step fails, the debit is also rolled back — money isn't lost
ConsistencyTotal balance across both accounts remains mathematically correct
IsolationAnother transaction checking balances won't see a half-completed transfer
DurabilityOnce confirmed, the transfer survives even a server crash

Why ACID Matters

ACID compliance is critical for systems where data accuracy is non-negotiable, such as banking, healthcare, and e-commerce order processing. Most traditional relational databases like MySQL (InnoDB), PostgreSQL, and Oracle are fully ACID-compliant by design.

Understanding ACID properties naturally leads into the broader topic of transactions, which is where these guarantees are actually implemented and enforced.

Ready to master DBMS & SQL Training Course?

Join Uncodemy's hands-on training with mentor support and placement assistance.

Explore Course

How the Database Actually Delivers Each Guarantee

ACID is not magic. Each letter is backed by a specific mechanism inside the storage engine.

  • Atomicity relies on an undo log. Before a row changes, the old version is recorded so the engine can put it back if the transaction is rolled back or the server restarts mid-way.
  • Durability relies on write-ahead logging. The change is written to a redo log and flushed to disk at commit time, before the data pages themselves are updated. After a crash, the engine replays the log.
  • Isolation relies on locks and, in engines such as InnoDB and PostgreSQL, multi-version concurrency control. Readers see a consistent snapshot while writers prepare new versions.
  • Consistency is shared work. The database enforces primary keys, foreign keys, NOT NULL, CHECK constraints and triggers, while business rules that the schema cannot express must be enforced by the application.

Seeing It in MySQL

The bank transfer can be written as a real transaction. The CHECK constraint stops any account going below zero, which is the consistency rule for this example.

CREATE TABLE accounts (
    id      INT PRIMARY KEY,
    holder  VARCHAR(50),
    balance DECIMAL(12,2) NOT NULL CHECK (balance >= 0)
) ENGINE = InnoDB;

INSERT INTO accounts VALUES (1, 'Account A', 8000), (2, 'Account B', 2000);

START TRANSACTION;
UPDATE accounts SET balance = balance - 5000 WHERE id = 1;
UPDATE accounts SET balance = balance + 5000 WHERE id = 2;
COMMIT;

-- Try to overdraw: the first UPDATE fails the CHECK
START TRANSACTION;
UPDATE accounts SET balance = balance - 9000 WHERE id = 1;  -- error
ROLLBACK;

Older MySQL versions parsed CHECK constraints but ignored them, so confirm that your version enforces them before relying on one.

Isolation Levels and the Anomalies They Allow

Full isolation is expensive, so SQL defines levels that trade safety for concurrency. Each level blocks a different set of read anomalies.

LevelDirty readNon-repeatable readPhantom read
READ UNCOMMITTEDPossiblePossiblePossible
READ COMMITTEDPreventedPossiblePossible
REPEATABLE READPreventedPreventedPossible in the standard
SERIALIZABLEPreventedPreventedPrevented

A dirty read sees uncommitted data from another transaction. A non-repeatable read gets a different value when reading the same row twice. A phantom read finds new rows appearing in a repeated range query. InnoDB defaults to REPEATABLE READ and uses gap locking to block most phantoms. You can check and change the level per session:

SELECT @@transaction_isolation;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;

Misunderstandings That Cause Real Bugs

  • Believing a failed statement rolls back the whole transaction. In MySQL, most errors undo only the failing statement. Your code must issue ROLLBACK itself, or the earlier successful updates can still be committed.
  • Using a non-transactional engine. MyISAM tables ignore START TRANSACTION, so ACID guarantees do not apply.
  • Forgetting autocommit. Without an explicit transaction, each statement commits on its own, splitting what should be one unit of work.
  • Mixing up ACID consistency with distributed consistency. The C in CAP is about replicas agreeing, which is a different idea.

Many NoSQL systems relax these guarantees and describe themselves as BASE: basically available, soft state, eventually consistent. That suits activity feeds and analytics counters, but money, stock levels and medical records still call for proper ACID transactions.