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
Indexing
Indexing ek technique hai jo database ke data ko fast search karne mein help karti hai — jaise book ke end mein index hota hai, jisse aap kisi topic ka page number directly dekh sakte ho.
Agar index nahi hoga to database ko har row ek-ek karke check karni padegi (isko full table scan bolte hain) — jo slow hota hai.
Index = Fast searching
No Index = Slow searching
Real-Life Example
Sochiye aapke paas ek phone directory hai:
Agar index nahi hai to aapko har page dekhna padega kisi naam ke liye.
Agar index hai to aap seedha “S” section pe jaa sakte ho “Suresh” dhoondhne ke liye.
SQL Indexing bhi aise hi kaam karta hai — directly relevant data tak pahuch jaata hai.
Indexing kaise kaam karta hai
Jab aap kisi column par index create karte ho, DBMS ek alag data structure banata hai (jaise B-Tree ya Hash Table) jisme:
Column ki values hoti hain
Un values ki pointer hoti hai original row tak
Employees Table Example
EmpID | Name | Age | Department |
---|---|---|---|
101 | Aditi | 25 | HR |
102 | Ravi | 30 | IT |
103 | Neha | 28 | Finance |
104 | Suresh | 35 | IT |
Agar hum Name
column par index banate hain:
Index Table
Name | Pointer to Row |
---|---|
Aditi | → Row 1 |
Neha | → Row 3 |
Ravi | → Row 2 |
Suresh | → Row 4 |
Ab query:
SELECT * FROM Employees WHERE Name = 'Neha';
Direct Row 3 par jaayegi — fast!
Types of Indexes
1. Single Column Index
Ek column par banta hai:
CREATE INDEX idx_emp_name ON Employees(Name);
2. Composite Index
2 ya usse zyada columns pe:
CREATE INDEX idx_emp_dept_age ON Employees(Department, Age);
3. Unique Index
Duplicate values allow nahi karta:
CREATE UNIQUE INDEX idx_emp_id ON Employees(EmpID);
4. Primary Key Index
Jab aap primary key banate ho to DBMS automatically index bhi bana deta hai.
Indexing ke Fayde
Fayda | Kya hota hai |
---|---|
Fast Search | SELECT queries fast ho jaati hain |
Efficient Search | WHERE aur JOIN mein fast results milte hain |
Sorting Mein Help | ORDER BY aur GROUP BY fast ho jaata hai |
CPU Load Kam | Fewer rows scan karne padti hain |
Indexing ke Nuksaan
Nuksaan | Kya hota hai |
---|---|
Slow Insert/Update | Har bar index bhi update karna padta hai |
Extra Space Lagta Hai | Index file space leti hai |
Bahut zyada indexes | Performance down kar sakta hai (manage karna mushkil) |
Example – Query Speed with Index
Suppose Students
table mein 1 million rows hain:
Without index:
SELECT * FROM Students WHERE RollNo = 500123;
Full table scan — slow
With index:
CREATE INDEX idx_rollno ON Students(RollNo);
Index scan — super fast
Diagram: Indexing Concept
Main Table
+-------+------+-----+
| EmpID | Name | Age |
+-------+------+-----+
| 101 | Aditi | 25 |
| 102 | Ravi | 30 |
| 103 | Neha | 28 |
+-------+-------+----+
Index on Name (B-Tree)
Neha
/ \
Aditi Ravi
\
Suresh
Index → Directly points to row in main table
Kab Index Use Karna Chahiye?
Index Use Karo jab:
WHERE clause mein bar bar use ho raha ho
Column foreign key ho
Table bahut bada ho
Index ko avoid karo jab:
Table chhoti ho
Column mein zyada duplicate values ho (like gender)
Summary Table
Topic | Summary |
---|---|
Kya hai? | Search ko fast banata hai |
Kis pe kaam karta hai? | Columns (single ya multiple) |
Types | Single, Composite, Unique, Primary Key |
Fayde | Fast SELECT, better performance |
Nuksaan | Slower inserts/updates, extra storage needed |