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
Integrity Constraints in DBMS
Integrity Constraints kya hote hain?
Integrity Constraints kuch rules hote hain jo hum database par lagate hain taaki data:
-
-> Sahi ho (Valid)
-
-> Consistent ho (Maitlab, logically theek ho)
-
-> Reliable ho (Galat ya missing na ho)
Ye constraints ensure karte hain ki koi bhi invalid ya galat data database me na jaaye.
Example Samjho:
Maan lo ek Student
table hai. Aap chahte ho ki:
-
Har student ka ID unique ho
-
Naam khaali (empty) na ho
-
Age 0 se zyada ho
In sab rules ko Integrity Constraints kehte hain.
Types of Integrity Constraints
Type | Kya kaam karta hai? |
---|---|
1. Domain Constraint | Data ka type check karta hai |
2. Entity Integrity | Primary key ko unique aur non-null banata hai |
3. Referential Integrity | Tables ke beech relation maintain karta hai |
4. Unique Constraint | Unique values enforce karta hai |
5. Not Null Constraint | NULL (empty) values ko allow nahi karta |
6. Check Constraint | Custom condition lagata hai value par |
1. Domain Constraint
Ye ensure karta hai ki column me correct data type ka hi value aaye.
Example:
CREATE TABLE Student (
ID INT,
Name VARCHAR(50),
Age INT
);
-
ID
sirf integer le sakta hai -
Name
max 50 characters ka text -
Age
me text nahi aana chahiye
Iska kaam: Galat data type ko rokna
2. Entity Integrity Constraint
Ye ensure karta hai ki har row ka ek unique aur non-null primary key ho.
Example:
CREATE TABLE Student (
ID INT PRIMARY KEY,
Name VARCHAR(50)
);
Rules:
-
Har
ID
unique ho -
ID
null nahi ho sakta
Diagram:
+----+------+
| ID | Name |
+----+------+
| 1 | Riya |
| 2 | Aman |
| | X (NULL not allowed) |
| 1 | X (Duplicate not allowed) |
3. Referential Integrity Constraint
Ye foreign key ka use karke tables ke beech relation banata hai.
Example:
Student Table:
CREATE TABLE Student (
ID INT PRIMARY KEY,
Name VARCHAR(50)
);
Course Table:
CREATE TABLE Course (
CourseID INT PRIMARY KEY,
StudentID INT,
FOREIGN KEY (StudentID) REFERENCES Student(ID)
);
Rule:
-
Course
table me aisaStudentID
nahi ho sakta joStudent
table me exist nahi karta.
Diagram:
Student Table
+----+------+
| ID | Name |
+----+------+
| 1 | Riya |
| 2 | Aman |
+----+------+
Course Table
+------+-----------+
| C_ID | StudentID |
+------+-----------+
| 101 | 1 |
| 102 | 3 X (3 exist nahi karta)
4. Unique Constraint
Ye ensure karta hai ki column ke saare values unique ho, lekin null value allowed hai.
Example:
CREATE TABLE Employee (
EmpID INT,
Email VARCHAR(100) UNIQUE
);
Rule:
-
Do employees ka email same nahi ho sakta.
-
5. NOT NULL Constraint
Ye ensure karta hai ki column me NULL (khaali) value nahi aaye.
Example:
CREATE TABLE Student (
ID INT,
Name VARCHAR(50) NOT NULL
);
Rule:
-
Name
column me value dena zaroori hai.
6. Check Constraint
Ye ek custom condition lagata hai values ke liye.
Example:
CREATE TABLE Student (
ID INT,
Age INT CHECK (Age >= 18)
);
Rule:
-
Age 18 ya usse zyada honi chahiye.
Wrong Query:
INSERT INTO Student (ID, Age) VALUES (1, 16); -- Not allowed
Summary Table
Constraint Type | Kya ensure karta hai? |
---|---|
Domain Constraint | Correct data type aana |
Entity Integrity | Primary key unique & non-null ho |
Referential Integrity | Tables ke relations valid ho |
Unique Constraint | Unique values ho column me |
Not Null Constraint | Null value na aaye |
Check Constraint | Condition satisfy ho |