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
Complex Queries in SQL
Complex Query kya hoti hai?
Complex Query woh hoti hai jo basic SELECT se zyada advance ho. Isme hum:
-> Multiple tables ka use karte hain (JOINs)
-> Queries ke andar queries (Subqueries)
-> Grouping aur filtering (GROUP BY, HAVING)
-> Data merge karte hain (UNION)
-> Ya phir conditions lagate hain (CASE)
Complex queries se hum real-life jaise problems solve kar sakte hain jahan simple query kaam nahi karti.
Complex Queries ke Main Parts
Chaliye dekhte hain kya-kya cheezein ek complex query banati hain:
1. JOIN
Do ya zyada tables ka data jodne ke liye.
2. Subquery (Nested Query)
Ek query ke andar doosri query.
3. Aggregate Functions
Jaise SUM(), AVG(), COUNT() ke saath GROUP BY.
4. Set Operators
Jaise UNION, INTERSECT, EXCEPT.
Example Tables
Students Table
| StudentID | Name | Age | DeptID |
|---|---|---|---|
| 1 | Riya | 20 | 101 |
| 2 | Aman | 21 | 102 |
| 3 | Nidhi | 22 | 103 |
Departments Table
| DeptID | DeptName |
|---|---|
| 101 | Computer Sci |
| 102 | Mechanical |
| 103 | Electrical |
Example 1: JOIN ka Use
Q: Har student ka naam aur uska department naam chahiye.
SELECT Students.Name, Departments.DeptName
FROM Students
JOIN Departments ON Students.DeptID = Departments.DeptID;
Output:
| Name | DeptName |
|---|---|
| Riya | Computer Sci |
| Aman | Mechanical |
| Nidhi | Electrical |
Yahan JOIN se dono tables ka data joda gaya hai.
Example 2: Subquery ka Use
Q: Aise students jinki age average se zyada ho.
SELECT Name, Age
FROM Students
WHERE Age > (
SELECT AVG(Age)
FROM Students
);
Agar average age 21 hai to output:
| Name | Age |
|---|---|
| Nidhi | 22 |
Yahan andar wali query AVG(Age) nikaal rahi hai.
Example 3: GROUP BY + HAVING
Q: Har department mein kitne students hain, sirf wahi dikhayein jahan count 1 se zyada ho.
SELECT DeptID, COUNT(*) AS StudentCount
FROM Students
GROUP BY DeptID
HAVING COUNT(*) > 1;
GROUP BY group banata hai aur HAVING us par condition lagata hai.
Example 4: UNION ka Use
Q: Students aur departments ke naam ek hi column mein chahiye.
SELECT Name AS Info
FROM Students
UNION
SELECT DeptName AS Info
FROM Departments;
UNION se dono results combine ho jaate hain (duplicate hata ke).
Example 5: CASE Statement
Q: Har student ke age group ko category mein dikhana hai.
SELECT Name,
CASE
WHEN Age < 20 THEN 'Teen'
WHEN Age BETWEEN 20 AND 22 THEN 'Young Adult'
ELSE 'Adult'
END AS AgeGroup
FROM Students;
CASE conditional logic ke liye use hota hai.
Complex Queries ke Components Summary
| Feature | Use Karne Ka Reason |
|---|---|
| JOIN | Multiple tables ka data jodne ke liye |
| Subquery | Query ke andar query use karne ke liye |
| GROUP BY | Data ko group karne ke liye |
| HAVING | Grouped data pe filter lagane ke liye |
| UNION | Multiple results ko combine karne ke liye |
| CASE | Conditional values dene ke liye |
Tips for Students
-> Pehle simple query likho
-> Complex query ko steps mein socho
-> AS (alias) ka use karo clarity ke liye
-> Practice karo real examples par