Keys in DBMS in Hindi - DBMS में Keys क्या होती हैं?
Keys in DBMS in Hindi
Table of Contents
- Super Key in dbms in hindi(सुपर की इन हिंदी)
- Candidate Key in dbms in hindi(कैंडिडेट की इन हिंदी)
- Primary Key in dbms in hindi (प्राइमरी की इन हिंदी)
- Alternate Key in dbms in hindi(ऑल्टरनेट की इन हिंदी)
- Foreign Key in dbms in hindi(फॉरेन की इन हिंदी)
- Composite Key in dbms in hindi(कंपोजिट की इन हिंदी)
- Unique Key in dbms in hindi(यूनिक की इन हिंदी)
Keys in DBMS in Hindi (DBMS में Keys क्या होती हैं?)
Keys in DBMS ऐसे attributes (columns) या attributes के group होते हैं जो database table में records (rows) को uniquely identify करने के लिए use किए जाते हैं।
Simple words में, Key = किसी भी record की unique पहचान होती है।
Keys की जरूरत क्यों होती है?
- हर record को uniquely identify करने के लिए
- Data redundancy (duplicate data) को कम करने के लिए
- Tables के बीच relationship बनाने के लिए
- Data integrity बनाए रखने के लिए
Example से समझें
मान लीजिए एक Student Table है:
| Roll No | Name | Class |
|---|---|---|
| 101 | Rahul | 10th |
| 102 | Aman | 10th |
यहाँ Roll No हर student के लिए unique है, इसलिए यह Primary Key बन सकता है।
types of keys in dbms in hindi
1. Super Key in dbms in hindi
Super Key वह attribute या attribute का combination होता है जो किसी भी record को uniquely identify करता है। इसे Unique Identifier भी कहा जाता है। मतलब एक table में कोई दो rows एक ही Super Key के value के साथ नहीं हो सकते।
- हर Primary Key एक Super Key होती है, लेकिन हर Super Key Primary Key नहीं होती।
- Super Key में unnecessary attributes भी हो सकते हैं।
उदाहरण: अगर हमारे पास Student table है जिसमें attributes हैं: Roll_No, Name, Email, Phone।
तो Super Key हो सकती है {Roll_No}, {Email}, {Roll_No, Name} आदि।
| Super Key | Explanation |
|---|---|
| {Roll_No} | एकमात्र Roll_No से student को uniquely पहचान सकते हैं। |
| {Email} | Email भी यूनिक होती है, इसलिए Super Key मानी जा सकती है। |
| {Roll_No, Name} | यह भी uniquely identify कर सकती है, लेकिन extra attribute है। |
2. Candidate Key in dbms in hindi
Candidate Key वह Super Key होती है जिसमें कोई भी unnecessary attribute नहीं होता। यानी, यह minimal Super Key होती है। Candidate Key का उपयोग Primary Key चुनने के लिए किया जाता है।
- हर Candidate Key unique होती है।
- एक table में एक से अधिक Candidate Keys हो सकती हैं।
उदाहरण: Student Table में Roll_No और Email दोनों ही Candidate Keys हो सकती हैं।
3. Primary Key in dbms in hindi
Primary Key वह Candidate Key होती है जिसे table के प्रत्येक record को uniquely identify करने के लिए चुना जाता है। यह NULL values को स्वीकार नहीं करती और Duplicate values की अनुमति नहीं देती।
- Primary Key डेटा की integrity बनाए रखती है।
- हर table में केवल एक Primary Key होती है।
उदाहरण: Roll_No को Primary Key बनाया जा सकता है क्योंकि यह हर student के लिए unique है।
| Property | Primary Key |
|---|---|
| Uniqueness | हर रिकॉर्ड के लिए Unique होती है। |
| Null Allowed | नहीं |
| Duplicate Values | नहीं |
4. Alternate Key in dbms in hindi
जब किसी table में एक से अधिक Candidate Keys होती हैं, तो जो Key Primary Key के रूप में select नहीं की जाती, उसे Alternate Key कहा जाता है। इसे Secondary Key भी कहते हैं।
- Alternate Key भी record को uniquely पहचान सकती है।
- यह Primary Key के alternative के रूप में काम करती है।
उदाहरण: यदि Roll_No Primary Key है, तो Email Alternate Key होगी।
5. Foreign Key in dbms in hindi
Foreign Key का उपयोग दो tables के बीच relationship बनाने के लिए किया जाता है। यह किसी table की Primary Key को दूसरे table में reference करती है।
- Foreign Key referential integrity बनाए रखती है।
- यह duplicate values रख सकती है लेकिन Primary Key values से match करनी चाहिए।
उदाहरण: अगर हमारे पास Student और Department tables हैं,
तो Department_ID Student table में Foreign Key हो सकती है जो Department table की Primary Key को reference करती है।
| Table | Attribute | Key Type |
|---|---|---|
| Department | Department_ID | Primary Key |
| Student | Department_ID | Foreign Key |
6. Composite Key in dbms in hindi
Composite Key वह Key होती है जो एक से अधिक attributes को मिलाकर बनाई जाती है ताकि किसी record को uniquely identify किया जा सके। यह तब उपयोगी होती है जब एक single attribute sufficient नहीं होता।
- Composite Key हमेशा multiple columns से मिलकर बनती है।
- यह Candidate Key भी हो सकती है।
उदाहरण: {Student_ID, Course_ID} एक Composite Key हो सकती है जो किसी student द्वारा लिए गए course को uniquely पहचानती है।
7. Unique Key in dbms in hindi
Unique Key किसी भी record को uniquely identify करने के लिए उपयोग की जाती है लेकिन इसमें NULL value की अनुमति होती है। यह Primary Key के समान होती है पर कुछ flexibility देती है।
- Unique Key duplicate values को रोकती है।
- एक table में multiple Unique Keys हो सकती हैं।
उदाहरण: Email field को Unique Key बना सकते हैं ताकि दो users का email address समान न हो।
Keys के बीच Comparison (कीज के बीच तुलना)
| Key Type | Uniqueness | Null Allowed | Duplicates Allowed |
|---|---|---|---|
| Primary Key | Yes | No | No |
| Unique Key | Yes | Yes | No |
| Foreign Key | No | Yes | Yes |
| Composite Key | Yes | No | No |