ACID means Atomicity, Consistency, Isolation and Durability.  Lets look at each of these properties with examples below

Atomicity:

Each transaction is all or nothing

Example:

When user purchases any item and does payment, let’s assume we have two transactions.

  1. To mark the item as purchased
  2. Reduce the inventory of that item

If first transaction fails, then next one will also be a failure. Both will happen together

Consistency:

Data should be valid according to all defined rules & remains in consistent state

Example:

It enforces all defined rules (Primary key, foreign key constraints etc). Consistent will ensure database remains in consistent state before & after the transaction is over.

Isolation:

Transactions don’t affect each other

Example:

User A & user B tries to purchase same item and available quantity is 1. With isolation in place, purchase transaction for each user will be separate. When user A click on purchase button first, then item will be locked for him. At the same time, user B will be shown with no item available.

Durability:

Committed data would not be lost, even when there is power failure

Example:

Let’s assume when user tries to adding items to cart for purchase, server goes down. Expectation of durability of database is that the transaction performed by user is available once server is up.