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
Joins in DBMS
Jab data alag-alag tables mein store kiya jaata hai, tab un tables ko ek saath laane ke liye Join use kiya jaata hai.
Join ek SQL operation hai jo 2 ya usse zyada tables ke rows ko combine karta hai based on koi common column.
Join kyun use karte hain?
Maan lo aapke paas 2 tables hain:
-
Students– jisme student ke naam aur department ID hai. -
Departments– jisme department ka naam hai.
Ab aap chahte ho ki har student ke saath uska department ka naam bhi dikhe — ye possible hoga Join ki madad se.
Example Tables
Table: Students
| StudentID | Name | DeptID |
|---|---|---|
| 1 | Riya | 101 |
| 2 | Aman | 102 |
| 3 | Nidhi | 103 |
Table: Departments
| DeptID | DeptName |
|---|---|
| 101 | Computer Sci |
| 102 | Mechanical |
| 104 | Civil |
Types of Joins
1. INNER JOIN
Sirf wahi rows dikhata hai jahan dono tables mein matching value hoti hai.
SQL Example:
SELECT Students.Name, Departments.DeptName
FROM Students
INNER JOIN Departments
ON Students.DeptID = Departments.DeptID;
Result:
| Name | DeptName |
|---|---|
| Riya | Computer Sci |
| Aman | Mechanical |
Diagram:
Students Departments
+--------+ +--------+
| DeptID | | DeptID |
+--------+ +--------+
| 101 | --> | 101 | Match
| 102 | --> | 102 | Match
| 103 | --> | (Not Found)| No Match
2. LEFT JOIN (LEFT OUTER JOIN)
Left table (Students) ke sabhi rows show karega, aur right table (Departments) ke sirf matching rows. Match na ho toh NULL show karega.
SQL Example:
SELECT Students.Name, Departments.DeptName
FROM Students
LEFT JOIN Departments
ON Students.DeptID = Departments.DeptID;
Result:
| Name | DeptName |
|---|---|
| Riya | Computer Sci |
| Aman | Mechanical |
| Nidhi | NULL |
3. RIGHT JOIN (RIGHT OUTER JOIN)
Right table (Departments) ke sabhi rows show karega, aur left table (Students) ke sirf matching rows. Match na ho toh NULL show karega.
SQL Example:
SELECT Students.Name, Departments.DeptName
FROM Students
RIGHT JOIN Departments
ON Students.DeptID = Departments.DeptID;
Result:
| Name | DeptName |
|---|---|
| Riya | Computer Sci |
| Aman | Mechanical |
| NULL | Civil |
4. FULL OUTER JOIN
Dono tables ke sabhi rows show karega — match ho toh dono ka data, warna NULL jahan match nahi ho.
Note: MySQL mein direct support nahi hota, par PostgreSQL, SQL Server mein hota hai.
Result:
| Name | DeptName |
|---|---|
| Riya | Computer Sci |
| Aman | Mechanical |
| Nidhi | NULL |
| NULL | Civil |
5. CROSS JOIN
Dono tables ke sabhi combinations deta hai — har row of table 1 ke saath table 2 ki har row.
SQL Example:
SELECT Students.Name, Departments.DeptName
FROM Students
CROSS JOIN Departments;
Agar 3 students × 3 departments = 9 rows banengi
Join Types Summary
| Join Type | Non-Matching Rows? | Use Case |
|---|---|---|
| INNER JOIN | Nahi | Sirf matching data chahiye |
| LEFT JOIN | Left table ka sab | Sabhi students dikhane ke liye |
| RIGHT JOIN | Right table ka sab | Sabhi departments dikhane ke liye |
| FULL OUTER JOIN | Dono ka | Sab kuch dikhana ho |
| CROSS JOIN | Match ki zarurat nahi | Sabhi combinations ke liye |
Conclusion
Joins help karte hain:
-
-> Alag-alag tables ka data combine karne mein.
-
-> Structured aur normalized data ko ek saath dikhane mein.
-
-> Query ko zyada meaningful aur powerful banane mein.