Transaction Management & ACID Properties
Transaction, kaam ka ek logical unit hai (e.g., bank se paisa transfer karna). Yeh ya to poora hoga (COMMIT), ya bilkul nahi hoga (ROLLBACK). Transaction Management inhi operations ko safely manage karta hai.
ACID Properties: The 'Vachan' of a Database
Har transaction ko ye 4 vachan (properties) nibhaane padte hain. Ye DBMS ka backbone hain.
- A - Atomicity (All or Nothing): Transaction ek 'atom' ki tarah hai, jise toda nahi ja sakta. Ya to transaction ke saare operations successfully honge, ya ek bhi nahi hoga.
- C - Consistency (Staying Correct): Database transaction ke shuru hone se pehle aur khatam hone ke baad, hamesha ek valid (consistent) state me rahega.
- I - Isolation (You are Alone): Agar 100 log ek saath database use kar rahe hain, to har transaction ko lagega ki wo akela hai. Ek ka adhoora kaam doosre ko nahi dikhega.
- D - Durability (Permanence): Agar ek transaction successfully
COMMITho gaya, to uska result database me permanent ho jaata hai, chahe system crash ho jaye.
Concurrency Control
Isolation property ko aache se implement karne ke liye Concurrency Control techniques use hoti hain. Ye ensure karti hain ki jab multiple transactions ek saath chalein, to koi problem na ho.
- Two-Phase Locking (2PL): Yeh ek popular protocol hai jo serializability ko guarantee karta hai. Iske do phase hote hain: Growing Phase (sirf lock acquire karna) aur Shrinking Phase (sirf lock release karna).
- Deadlock: 2PL se deadlock ho sakta hai, jahan do ya zyada transactions ek doosre ka intezaar karte reh jaate hain.