Primary Key in DBMS – Simple और Composite Key Explained in Hindi | आसान भाषा में पूरी जानकारी

Primary Key in DBMS (2025) – आसान भाषा में पूरी जानकारी

डेटाबेस (Database) को समझने और उस पर काम करने के लिए हमें कुछ बुनियादी concepts की जानकारी होना ज़रूरी है। इन्हीं concepts में से एक है Primary Key। जब भी हम किसी relational database (RDBMS) में table बनाते हैं, तो हमें data को uniquely पहचानने के लिए primary key की ज़रूरत होती है।

इस आर्टिकल में हम जानेंगे – Primary Key क्या है, इसके प्रकार (Types), Rules और Example, ताकि आपको यह concept हमेशा के लिए clear हो जाए।

Primary Key क्या है? – Primary Key in DBMS

Primary Key किसी भी relational table में एक ऐसा column या columns का group होता है जो हर record को uniquely पहचानता है।

  • मतलब अगर आपकी table में लाखों records (rows) हों, तो primary key के values हर row में अलग-अलग होंगे।
  • किसी भी table में केवल एक primary key define की जा सकती है।
  • Primary key null (खाली) नहीं हो सकती और duplicate values भी नहीं रख सकती।

 

Primary Key के प्रकार (Types of Primary Key)

Primary Key मुख्य रूप से 2 प्रकार की होती है:

1. Simple Primary Key

  • जब primary key सिर्फ एक ही column/field से बनी हो, तो उसे simple primary key कहते हैं।
  • Example: अगर Student table है और उसमें Roll_Number column unique है, तो Roll_Number simple primary key होगा।
Simple Primary Key - Primary Key in DBMS
Simple Primary Key – Primary Key in DBMS

Example Table:

Roll_NumberNameClass
101Ravi10th
102Ankit10th
103Neha9th

यहाँ Roll_Number हर student को uniquely identify करता है।

2. Composite Primary Key

  • जब primary key एक से ज़्यादा columns से मिलकर बनती है, तो उसे composite primary key कहते हैं।
  • इसका use तब किया जाता है जब कोई single column records को uniquely identify नहीं कर पाता।
composite primary key
composite primary key

Example Table:

Student_IDSubject_CodeMarks
1ENG10180
1MATH10290
2ENG10170

यहाँ Student_ID और Subject_Code दोनों मिलकर primary key बनते हैं।

Primary Key के Rules (Properties of Primary Key)

Primary key को define करते समय कुछ rules का ध्यान रखना ज़रूरी है:

  1. Unique Value होना चाहिए – Primary key हर row को uniquely identify करे।
  2. Null Value नहीं होनी चाहिए – Primary key null values को allow नहीं करती।
  3. Single या Multi Column हो सकती है – Single column primary key को simple key कहते हैं और multi-column primary key को composite key कहते हैं।
  4. केवल एक Primary Key – किसी भी table में सिर्फ एक primary key हो सकती है।
  5. Limit – Composite primary key में अधिकतम 16 columns तक हो सकते हैं (DBMS limitation के अनुसार)।

 

Primary Key क्यों ज़रूरी है?

  • Data Consistency (डेटा की सही पहचान) बनाए रखने के लिए।
  • Data Integrity (डेटा की सटीकता) सुनिश्चित करने के लिए।
  • Duplicate और Null values से बचने के लिए।
  • Searching और Indexing fast करने के लिए।

 

Primary Key vs Unique Key (Difference)

FeaturePrimary KeyUnique Key
Null ValuesNot AllowedOne Null Allowed
No. of KeysOnly One per TableMultiple Unique Keys possible
PurposeRow uniquely identify करनाData uniqueness maintain करना

 

इन्हें भी पढ़े –

  1. DBMS क्या है DBMS के प्रकार और कार्य की पूरी जानकारी | DBMS In Hindi
  2. डेटाबेस यूजर्स क्या है?
  3. डेटा इंडिपेंडेंस क्या है
  4. DBMS के लाभ
  5. Characteristics Of DBMS In Hindi
  6. डेटा मॉडल क्या है?
  7. डेटाबेस स्कीमा क्या है
  8. इंस्टैंस क्या है
  9. डेटाबेस इंटरफ़ेस क्या है
  10. डेटाबेस लैंग्वेज क्या है
  11. Classification of DBMS in Hindi
  12. Entity Set in DBMS
  13. DBMS Architecture in Hindi
  14. Types of Data Models in Hindi
  15. Attributes in DBMS in Hindi
  16. Entity Set in DBMS (Hindi)
  17. Entity Types in DBMS (Hindi)
  18. Types of Attributes in DBMS
  19. ER Model in DBMS (E-R मॉडल) क्या है?
  20. Entities के बीच संबंध
  21. Domain in DBMS
  22. Tuples in DBMS
  23. SQL में Joins क्या हैं?

 

निष्कर्ष (Conclusion)

Primary key किसी भी relational database की backbone मानी जाती है। यह हर record को uniquely identify करने में मदद करती है और database को सही तरीके से manage करने का काम करती है। Simple और Composite primary keys का सही उपयोग करके आप अपने database design को और भी efficient और error-free बना सकते हैं।

अगर आप DBMS सीख रहे हैं या competitive exam की तैयारी कर रहे हैं, तो Primary Key का concept आपके लिए सबसे जरूरी topics में से एक है।

Leave a Comment