Skip to main content

Command Palette

Search for a command to run...

Understanding ACID in Databases

Why Your Bank Balance Doesn’t Randomly Change

Updated
3 min read
Understanding ACID in Databases
I

I am a Software Developer from Lagos, Nigeria.

Have you ever wondered why your bank balance doesn’t randomly change?

Every day, millions of people transfer money, withdraw cash, pay bills, and make online purchases. Behind the scenes, thousands of transactions are happening every second.

Yet you rarely see situations where money disappears halfway through a transfer or suddenly appears in your account without explanation.

Why is that?

One of the key reasons is something called ACID.

ACID is a set of principles used by databases to ensure that transactions are handled safely and reliably. It helps systems maintain accurate and trustworthy data, especially when performing important operations like transferring money.

ACID stands for:

• Atomicity
• Consistency
• Isolation
• Durability


Atomicity

Atomicity means a transaction must either complete fully or not happen at all.

Imagine sending ₦50,000 to a friend.

You expect two things to happen.

  1. The money leaves your account.

  2. The same amount appears in your friend’s account.

You never expect the money to leave your account and then disappear somewhere in the system.

Atomicity ensures that this never happens.

A transaction must either complete fully or not happen at all.

If the system deducts the money from your account but fails to credit your friend, the database cancels the entire operation and restores everything to its previous state, i.e., to the way it was before the transaction started.

In simple terms, either everything succeeds or nothing happens.


Consistency

Consistency ensures that the data in the database always follows defined rules.

For example, a banking system might have a rule like:

An account balance cannot go below zero.

If a transaction attempts to violate this rule, the database rejects the transaction.

Consistency ensures that the database always moves from one valid state to another valid state, keeping the data accurate and preventing impossible situations like negative balances or invalid records.


Isolation

Isolation becomes important when many transactions happen at the same time.

Imagine two ATMs trying to withdraw money from the same account at the same moment.

Without proper controls, both machines might read the same balance, and both withdrawals could succeed.

Isolation ensures that transactions behave as if they are happening one at a time, even when thousands of them are running simultaneously in the system.

This prevents transactions from interfering with each other.


Durability

Durability focuses on what happens after a transaction is completed.

Imagine transferring money, and immediately after that, the system crashes.

Without durability, the completed transaction might disappear.

Durability guarantees that once a transaction is successfully committed, it is permanently stored. Even if the system crashes, the database can recover the transaction when the system restarts.


ACID may sound like a complex database concept, but its purpose is simple.

It ensures that important operations happen safely, reliably, and predictably.

Every time you transfer money, place an online order, or pay a bill, ACID principles are likely working quietly behind the scenes to keep your data accurate.