DBMS
DBMS Part-1
- DBMS Introduction
- DBMS Architecture
- Database Approach vs Traditional File System
- Advantages of DBMS
- Data Models in DBMS
- Schemas in DBMS
- Instances in DBMS
- Data Independence in DBMS
- Database Languages in DBMS
- Interfaces in DBMS
- Structure of DBMS
- Functions of DBA and Designer
- Entities and Attributes in DBMS
- ER Diagram in DBMS
- Generalization, Specialization and Aggregation in DBMS
- Converting ER Diagram to Tables in DBMS
- Difference between Object Oriented, Network and Relational Data Models
DBMS Part-2
- Relational Data Model in DBMS
- Keys in DBMS
- SQL Introduction
- DDL(Data Definition Language)
- DML(Data Manipulation Language)
- Integrity Constraints in DBMS
- Complex SQL Queries
- Joins in DBMS
- Indexing in DBMS
- Triggers in DBMS
- Assertions in DBMS
- Relational Algebra in DBMS
- Tuple Relational Calculus in DBMS
- Domain Relational Calculus in DBMS
DBMS Part-3
- Introduction to Normalization in DBMS
- Normal Forms in DBMS
- Functional Dependency in DBMS
- Decomposition in DBMS
- Dependency Preserving Decomposition in DBMS
- Lossless Join Decomposition in DBMS
- Problems with Null Values and Dangling Tuples
- Multivalued Dependency in DBMS
- Query Optimization in DBMS
- Algorithms for Select, Project and Join Operations in DBMS
- Query Optimization Methods in DBMS
DBMS Part-4
- Transactions in DBMS
- Serializability in DBMS
- Recoverability in DBMS
- Recovery Techniques in DBMS
- Log Based Recovery in DBMS
- Checkpoint in DBMS
- Deadlock in DBMS
- Concurrency Control in DBMS
- Lock Based Protocol in DBMS
- Timestamp Based Protocol in DBMS
- Validation Based Protocol in DBMS
- Multiple Granularity in DBMS
- Multi-Version Concurrency Control(MVCC) in DBMS
- Recovery with Concurrent Transactions in DBMS
DBMS Part-5
Log Based Recovery in DBMS
Log-based recovery ek technique hai jisse hum database ko crash hone ke baad wapas recover kar sakte hain — jaise agar system band ho gaya ho, ya power cut ho gaya ho.
Ye technique ek special file ka use karti hai jise hum Log file kehte hain.
Log File kya hoti hai?
Log file ek aisi file hoti hai jisme har transaction ke steps likhe jaate hain. Agar system crash ho jaye, toh hum log file padke decide karte hain:
-
Kise dubara repeat (REDO) karna hai (agar transaction complete ho gaya tha),
-
Aur kise wapis (UNDO) lena hai (agar transaction adhoora tha).
Log file me kya likha hota hai?
[Transaction ID, Operation, Data Item, Old Value, New Value]
Example:
Agar T1
ne balance
ko 500 se 700 banaya, toh log record hoga:
[T1, WRITE, balance, 500, 700]
Types of Log Records
-
BEGIN Transaction → Jab transaction start hoti hai.
-
WRITE Operation → Jab koi value update hoti hai.
-
COMMIT → Jab transaction successfully complete ho jaati hai.
-
ABORT → Jab transaction cancel hoti hai.
Example Scenario
Maan lo 2 transactions chal rahi hain: T1
aur T2
.
Time | Log Entry |
---|---|
1 | BEGIN T1 |
2 | WRITE T1, X, 10, 20 |
3 | BEGIN T2 |
4 | WRITE T2, Y, 30, 40 |
5 | COMMIT T1 |
6 | System crash ho gaya |
Ab kya hoga?
-
T1
ne commit kar diya tha → isliye REDO karenge. -
T2
ne commit nahi kiya → isliye UNDO karenge.
REDO aur UNDO ka matlab
-
REDO → Committed transactions ke operations ko dubara apply karna.
-
UNDO → Adhoore transactions ke changes ko wapis lena (reverse karna).
Recovery Process Diagram
┌──────────┐ ┌──────────┐
│ Log File │────> │ Recovery │
│ │ │ Manager │
└──────────┘ └──┬───────┘
│
┌─
──────────▼─────────┐ │ REDO committed Txs │
│ UNDO uncommitted Txs│
└
─────────────────────┘
Log-based Recovery ke Fayde
-
Data consistent rehta hai.
-
System automatically recover kar leta hai.
-
REDO aur UNDO process easy ho jaati hai.
Summary Table
Term | Meaning (Simple) |
---|---|
Log | Transaction ka step-by-step record |
REDO | Jo complete ho gaya usse phir se apply karo |
UNDO | Jo adhoora raha uske changes ko hatao |
COMMIT | Transaction complete ho gaya |
ABORT | Transaction fail ya cancel ho gaya |