DBMS Keys, Constraints & Functional Dependency in Hindi (Complete Guide)
📌 Introduction
आज के डिजिटल समय में हर बड़ी वेबसाइट, ऐप और सिस्टम के पीछे एक Database System काम करता है। चाहे वह बैंकिंग सिस्टम हो, ई-कॉमर्स वेबसाइट हो या सोशल मीडिया प्लेटफॉर्म — हर जगह डेटा को सही तरीके से स्टोर और मैनेज करना जरूरी होता है।
इसी प्रक्रिया को आसान और व्यवस्थित बनाने के लिए Relational Database Management System (RDBMS) का उपयोग किया जाता है।
इस ब्लॉग में हम विस्तार से समझेंगे:
- Keys क्या होती हैं?
- Types of Keys in DBMS
- Integrity Constraints क्या हैं?
- Functional Dependency क्या होती है?
- Armstrong’s Axioms क्या हैं?
👉 यह पोस्ट खासकर students, beginners और competitive exam aspirants के लिए बहुत उपयोगी है।
🔑 What is Key in Relational Database?
Key एक attribute या attributes का combination होता है जो किसी table के हर record (tuple) को uniquely identify करता है।
👉 सरल भाषा में:
Key की मदद से हम database में हर row को अलग-अलग पहचान सकते हैं।
🔍 Key की आवश्यकता क्यों होती है?
- हर record को uniquely पहचानने के लिए
- Duplicate data को रोकने के लिए
- Data retrieval को fast बनाने के लिए
- Tables के बीच relationship बनाने के लिए
📊 Types of Keys in DBMS
Relational Database में कई प्रकार की keys होती हैं:
1. 🔹 Simple Key
जब कोई key केवल एक ही attribute से बनी हो, तो उसे Simple Key कहते हैं।
👉 Example:
Student table में Roll No एक simple key हो सकती है।
2. 🔹 Composite Key
जब key दो या दो से अधिक attributes से मिलकर बनी हो, तो उसे Composite Key कहते हैं।
👉 Example:
StudentID + CourseID
3. 🔹 Super Key
Super Key वह key होती है जो किसी record को uniquely identify कर सकती है।
👉 इसमें extra attributes भी हो सकते हैं।
4. 🔹 Candidate Key
Candidate Key वह minimal super key होती है जिसमें कोई extra attribute नहीं होता।
👉 यह सबसे optimal key होती है।
5. 🔹 Primary Key
Candidate Keys में से किसी एक को चुनकर Primary Key बनाया जाता है।
✔ Properties of Primary Key:
- Unique होना चाहिए
- NULL नहीं होना चाहिए
- एक table में केवल एक primary key होती है
6. 🔹 Alternate Key
जो candidate keys primary key नहीं बनतीं, उन्हें Alternate Keys कहते हैं।
7. 🔹 Foreign Key
Foreign Key वह attribute होता है जो किसी दूसरी table की primary key को refer करता है।
👉 यह tables के बीच relationship बनाता है।
🔗 Example:
- Student Table → Primary Key (StudentID)
- Course Table → Foreign Key (StudentID)
⚖️ Integrity Constraints in DBMS
📌 Integrity Constraints क्या हैं?
Integrity Constraints वे rules होते हैं जो database में data की accuracy और consistency बनाए रखते हैं।
👉 सरल शब्दों में:
यह database में गलत data को आने से रोकते हैं।
❓ Integrity Constraints की जरूरत क्यों होती है?
- गलत data entry को रोकने के लिए
- Data consistency बनाए रखने के लिए
- Database performance सुधारने के लिए
- Business rules को enforce करने के लिए
📚 Types of Integrity Constraints
1. 🔹 Domain Constraint
यह define करता है कि किसी attribute में किस प्रकार का data आएगा।
👉 Example:
Age → केवल numeric values (0–100)
2. 🔹 Key Constraint
यह सुनिश्चित करता है कि primary key unique हो।
3. 🔹 Entity Integrity Constraint
Primary key कभी भी NULL नहीं हो सकती।
4. 🔹 Referential Integrity Constraint
Foreign key हमेशा valid primary key को refer करे।
👉 Example:
अगर StudentID मौजूद नहीं है, तो उसे Course table में use नहीं किया जा सकता।
🔗 Functional Dependency in DBMS
📌 Functional Dependency क्या है?
Functional Dependency एक concept है जो बताता है कि एक attribute दूसरे attribute पर depend करता है।
👉 इसे इस तरह लिखा जाता है:
X → Y
👉 इसका मतलब:
X की value से Y की value निर्धारित होती है।
🔍 Example:
अगर:
Roll No → Name
👉 इसका मतलब:
हर Roll No के लिए Name unique होगा।
📊 Types of Functional Dependency
1. 🔹 Trivial Dependency
जब Y, X का subset हो
👉 Example:
A → A
2. 🔹 Non-Trivial Dependency
जब X और Y का कोई common element न हो
👉 Example:
A → B
3. 🔹 Semi-Trivial Dependency
जब X और Y का कुछ हिस्सा common हो
👉 Example:
AB → BC
📐 Armstrong’s Axioms
Functional Dependency को समझने और derive करने के लिए कुछ rules होते हैं जिन्हें Armstrong’s Axioms कहते हैं।
1. Reflexivity Rule
अगर B ⊆ A है, तो:
A → B
2. Augmentation Rule
अगर:
A → B
तो:
AC → BC
3. Transitivity Rule
अगर:
A → B और B → C
तो:
A → C
4. Union Rule
अगर:
A → B और A → C
तो:
A → BC
5. Decomposition Rule
अगर:
A → BC
तो:
A → B और A → C
6. Pseudotransitivity Rule
अगर:
A → B और BC → D
तो:
AC → D
📈 Real-Life Example
मान लीजिए एक Student Database है:
| StudentID | Name | Course |
|---|---|---|
| 101 | Ram | BCA |
| 102 | Shyam | MCA |
👉 यहाँ:
- StudentID → Name
- StudentID → Course
👉 इसलिए StudentID एक Primary Key है।
📌 Conclusion
इस ब्लॉग में हमने सीखा:
- Keys क्या होती हैं और उनके प्रकार
- Integrity Constraints कैसे काम करते हैं
- Functional Dependency क्या है
- Armstrong’s Rules क्या हैं
👉 अगर आप DBMS सीख रहे हैं या exam की तैयारी कर रहे हैं, तो ये topics बहुत important हैं।
💬 Leave a Comment & Rating