4.4.26 · HinglishDatabases

BASE vs ACID

1,915 words9 min readRead in English

4.4.26 · Coding › Databases


ACID — the strict contract


BASE — the relaxed contract


The bridge: CAP theorem (WHY yeh choice force hoti hai)

Figure — BASE vs ACID

Side-by-side

Aspect ACID BASE
Goal Abhi correctness Availability + scale
Consistency Strong, immediate Eventual
Availability Block/refuse kar sakta hai Hamesha respond karta hai
Typical DB PostgreSQL, MySQL, Oracle Cassandra, DynamoDB, Riak
Best for Paisa, inventory, bookings Feeds, likes, caches, analytics
CAP side CP AP


Recall Ek 12-saal ke bachche ko samjhao (hidden)

Socho ek notebook jise alag-alag shehar mein rehne wale dost share karte hain. ACID woh bahut careful dost hai: koi bhi kuch likhne se pehle, woh sabko call karta hai, sabko ek hi waqt mein update karwata hai, aur math double-check karta hai. Kabhi kuch galat nahi hota — lekin agar phone line down ho, toh woh likhne se hi mana kar deta hai jab tak theek na ho jaaye. BASE woh easy-going dost hai: woh apni notebook mein turant likh leta hai aur tumhara sawaal instantly answer karta hai. Notebooks thodi der ke liye alag-alag ho sakti hain, lekin jald hi sab baat karte hain aur ek jaise ho jaate hain. Tum kabhi wait nahi karte, lekin ek moment ke liye tumhara answer thoda purana ho sakta hai. Careful dost ko paison ke liye use karo. Easy-going dost ko "likes" count karne ke liye use karo.




Flashcards

ACID ka matlab kya hai?
Atomicity, Consistency, Isolation, Durability
BASE ka matlab kya hai?
Basically Available, Soft state, Eventual consistency
Atomicity kya guarantee karta hai?
Transaction ke saare operations succeed hote hain ya koi bhi nahi (koi partial application nahi)
Isolation kya guarantee karta hai?
Concurrent transactions interfere nahi karte; result kisi serial order ke barabar hota hai
Durability kya guarantee karta hai?
Committed data crashes se survive karta hai (permanent storage mein persist hota hai)
"Eventual consistency" kya promise karta hai?
Koi nayi writes na hon toh, saare replicas eventually same value par converge kar lete hain
BASE kyun exist karta hai?
Bahut saari machines mein immediate consistency relax karke high availability aur scale paane ke liye
CAP theorem: distributed systems mein kaunsi property non-negotiable hai?
Partition tolerance (P) — networks fail hote hi hain, chahe kuch bhi ho
ACID systems usually kaunsi CAP pair choose karte hain?
CP (consistency + partition tolerance, availability sacrifice karke)
BASE systems usually kaunsi CAP pair choose karte hain?
AP (availability + partition tolerance, strong consistency sacrifice karke)
Ek ACID-appropriate use case do.
Bank transfers / inventory / seat booking (galat data ki cost bahut zyada hai)
Ek BASE-appropriate use case do.
Like counts, news feeds, caches, analytics (staleness sasti hai)
ACID vs BASE choose karne ka decision rule kya hai?
ACID jab galat data ki cost >> downtime ki cost; BASE jab downtime cost dominate kare
True/false: BASE ka matlab hai kabhi bhi koi consistency nahi.
False — yeh eventual hai, absent nahi; replicas time ke saath converge karte hain

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