4.4.26Databases

BASE vs ACID

1,948 words9 min readdifficulty · medium6 backlinks

ACID — the strict contract


BASE — the relaxed contract


The bridge: CAP theorem (WHY the choice is forced)

Figure — BASE vs ACID

Side-by-side

Aspect ACID BASE
Goal Correctness now Availability + scale
Consistency Strong, immediate Eventual
Availability May block/refuse Always responds
Typical DB PostgreSQL, MySQL, Oracle Cassandra, DynamoDB, Riak
Best for Money, inventory, bookings Feeds, likes, caches, analytics
CAP side CP AP


Recall Explain it to a 12-year-old (hidden)

Imagine a notebook shared by friends in different cities. ACID is the super-careful friend: before anyone writes, he calls all the others, makes everyone update at the same instant, and double-checks the math. Nothing is ever wrong — but if a phone line is down, he just refuses to write until it's fixed. BASE is the easy-going friend: he writes in his own notebook right away and answers your question instantly. The notebooks might disagree for a little while, but soon they all chat and become the same again. You never wait, but for a moment your answer might be a bit old. Use the careful friend for money. Use the easy-going friend for counting "likes."




Flashcards

What does ACID stand for?
Atomicity, Consistency, Isolation, Durability
What does BASE stand for?
Basically Available, Soft state, Eventual consistency
Atomicity guarantees what?
All operations in a transaction succeed or none do (no partial application)
Isolation guarantees what?
Concurrent transactions don't interfere; result equals some serial order
Durability guarantees what?
Committed data survives crashes (persisted to permanent storage)
What does "eventual consistency" promise?
With no new writes, all replicas eventually converge to the same value
Why does BASE exist?
To get high availability and scale across many machines by relaxing immediate consistency
CAP theorem: which property is non-negotiable in distributed systems?
Partition tolerance (P) — networks fail regardless
ACID systems usually pick which CAP pair?
CP (consistency + partition tolerance, sacrificing availability)
BASE systems usually pick which CAP pair?
AP (availability + partition tolerance, sacrificing strong consistency)
Give an ACID-appropriate use case.
Bank transfers / inventory / seat booking (cost of wrong data is high)
Give a BASE-appropriate use case.
Like counts, news feeds, caches, analytics (staleness is cheap)
Decision rule for choosing ACID vs BASE?
ACID when cost of wrong data >> cost of downtime; BASE when downtime cost dominates
True/false: BASE means there is never any consistency.
False — it's eventual, not absent; replicas converge over time

Connections

  • CAP Theorem
  • ACID Transactions
  • Eventual Consistency
  • Distributed Systems
  • NoSQL Databases
  • Replication and Partitioning
  • Isolation Levels
  • Two-Phase Commit

Concept Map

why exists

sync is slow/fragile

strict choice

scalable choice

guarantees

includes

includes

includes

includes

includes

includes

includes

enables

cost

Correctness vs Availability tradeoff

Distributed systems

ACID strict contract

BASE relaxed contract

Transactions as one unit

Atomicity all or none

Consistency valid states

Isolation no interference

Durability survives crash

Basically Available always responds

Soft state changes over time

Eventual consistency replicas converge

High scale + availability

May see stale data

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, database ka basic sawaal hai: jab data bahut saari machines pe spread hota hai, toh hum correctness chahte hain ya speed/availability? Yahin se aata hai ACID vs BASE.

ACID ek strict bank-manager type system hai. Iske 4 rules: Atomicity (poora transaction ho ya bilkul na ho — half-half nahi), Consistency (saare rules/constraints hamesha valid rahein), Isolation (do log ek saath kaam karein toh ek-doosre ka data kharab na karein), aur Durability (commit ho gaya toh power chali jaaye tab bhi data safe). Money transfer, seat booking, inventory — yahaan ACID must hai, kyunki galat data ka cost bahut zyada hai.

BASE chill type system hai: Basically Available (hamesha jawaab dega, chahe thoda purana data ho), Soft state (data background sync se badalta rehta hai), Eventually consistent (thodi der baad saari replicas same ho jaati hain). Likes count, news feed, cache — yahaan 2 second purana data dikhe toh koi problem nahi, lekin slow ya down hona problem hai.

Inke beech ka pul hai CAP theorem: distributed system mein partition (network failure) toh hoga hi, isliye P pakka chahiye. Asli choice hai C vs A — ya toh consistent raho (ACID/CP, wait/refuse karo) ya available raho (BASE/AP, jawaab do aur baad mein sync karo). Rule simple: agar galat data ka nuksan zyada → ACID; agar downtime ka nuksan zyada → BASE. Real apps dono mix karte hain — payment ke liye ACID, feed ke liye BASE.

Go deeper — visual, from zero

Test yourself — Databases

Connections