Skip to main content

ACID

It's not a database only feature

ACID isn't just a database feature. Databases only apply it strictly.

It's about how transactions behave.

  1. Atomicity - All steps in a transaction form one bundle. They all pass or all fail together.
  2. Consistency - The system stays valid before and after it runs. It must not break the system rules. The state always obeys them. For example, any data written must follow all the rules. These include constraints, PK, FK, cascades, and triggers. Only valid data is written.
  3. Isolation - Parallel transactions don't interfere. Uncommitted ones stay hidden from the rest. Locking and MVCC are ways to give isolation.
  4. Durability - Once a transaction commits, it stays. This holds through power loss, crashes, or errors. With replication, the data is copied to all the nodes.
Atomicity meaning

Atomicity in programming isn't the same as in databases. See Atomic Variables for more.

Isolation meaning

The database quietly reorders the work. It looks like transactions ran one by one. This is just serialization.

consistency is an app level feature

The app must ensure consistency. It uses the database's atomicity and isolation to do so.

Isolation vs Concurrency

These two differ in a subtle way. Concurrency lets many clients use one data set. Isolation keeps them from harming it.

Mental model to remember

Think of a bank transaction to recall ACID.

  1. A - All or nothing
  2. C - Correct state
  3. I - Independent transactions
  4. D - Don't lose committed data