DEV Community

Cover image for ACID Properties in a Database Management System (DBMS) Explained in a Simple English.
Chukwuebuka
Chukwuebuka

Posted on • Edited on

ACID Properties in a Database Management System (DBMS) Explained in a Simple English.

ACID properties in a Database Management System (DBMS) ensure data stays accurate, reliable, and consistent during transactions, even with multiple users.

ACID stands for:
A — Atomicity
C — Consistency
I — Isolation
D — Durability

Let’s explain each one below.

Atomicity, also called “All or Nothing,” ensures that a transaction's operations are either fully complete or not applied to the database. If any part of the transaction fails, the database rolls back to its original state.

For example, in a banking system:

- Bob has $1000, and Joe has $700.
- Bob transfers $200 to Joe.
Enter fullscreen mode Exit fullscreen mode

This involves two operations marked as success:

- Debit $200 from Bob's account.
- Credit $200 to Joe's account.
Enter fullscreen mode Exit fullscreen mode

If Bob's account is debited, but Joe's isn't credited, the transaction fails. Atomicity ensures both actions succeed together or not at all.
Atomicity ensures transactions are aborted if a failure occurs and rolls back any changes that might have happened or commits the changes if all is successful.

Consistency ensures the database remains in a valid state before and after a transaction.
What this simply means is that before the start of the transaction, if we have a total number of 100, after the transaction, it should also be the same.

Using the banking example above:

- Before the transaction, Bob has $1000, and Joe has $700, for a 
  total of $1700.
- After the transaction, Bob has $800, and Joe has $900. The total 
  remains $1700.
Enter fullscreen mode Exit fullscreen mode

Consistency guarantees that even though individual values changed, the overall state of the database is correct.

Isolation ensures that transactions do not interfere with each other, preserving database consistency. Each transaction should execute independently as if it is the only one running.
Using the banking example:

 - While Bob transfers $200 to Joe, he also spends $200 at a 
   restaurant.
 - If both transactions run simultaneously, they might both read 
   Bob's initial balance of $1000, causing his final balance to 
   incorrectly be $800.
Enter fullscreen mode Exit fullscreen mode

With Isolation, one transaction completes first (e.g., the transfer), updating Bob's balance. The second transaction (e.g., the restaurant payment) then uses the updated balance, ensuring accurate results.

Durability ensures that once a transaction is successfully completed, its changes to the database are permanent, even in the event of a system failure.

Using the banking example:

- After Bob's payment to the restaurant is confirmed, the database 
  securely saves the change.
- Even if the system crashes (e.g., due to a power outage), the 
  payment remains recorded, and Bob's updated balance is preserved.
Enter fullscreen mode Exit fullscreen mode

This guarantees that completed transactions are not lost.

I hope this explanation simplifies the concept for you. If any part is still unclear or you’d like further clarification, feel free to let me know in the comments. I’d be happy to explain further. Thank you!

Top comments (0)