DBMS में Keys क्या हैं और उनके प्रकार (Types of Keys in DBMS in Hindi)

RDBMS में Keys का इस्तेमाल Table में किसी भी Row को विशेष रूप से पहचानने, डेटा की शुद्धता (Integrity) बनाए रखने और दो Tables के बीच संबंध (Relationship) स्थापित करने के लिए किया जाता है।

RDBMS में निम्नलिखित प्रकार की keys होती हैं।

1:- Primary Key

किसी relational table की primary key टेबल के प्रत्येक record को uniquely identify करता है। Primary key दो प्रकार की होती है।

  1. Simple primary key
  2. Composite primary key

1. Simple Primary Key:- Simple primary key केवल एक field (column) से मिलकर बनी होती है।
image

2. Composite Primary Key:- Composite primary key एक से अधिक fields (columns) से मिलकर बनी होती है।
image

Primary Key की विशेषताएं:

  • यह हमेशा unique होती है
  • एक table में केवल एक primary key होती है
  • यह single या multi column हो सकती है
  • इसमें NULL value नहीं होती
  • यह duplicate values को allow नहीं करती

2:- Foreign Key

Foreign key एक या अधिक columns का समूह होता है जो दो tables के बीच link बनाता है।
इसे referencing key भी कहा जाता है।

जब एक table की primary key को दूसरे table में use किया जाता है, तो वह foreign key कहलाती है।
यह data integrity बनाए रखने में मदद करती है।

3:- Composite key

जब टेबल में कोई एक अकेला Column रिकॉर्ड को पहचानने के लिए काफी नहीं होता, तब दो या दो से अधिक Columns को मिलाकर एक Key बनाई जाती है, जिसे Composite Key कहते हैं।

image

4. Artificial key

Artificial key (Surrogate Key) तब उपयोग की जाती है जब:

  • किसी attribute में primary key की सभी properties नहीं होती
  • या primary key बहुत बड़ी और complex होती है

यह एक extra generated key होती है जैसे ID number।

5- Super Key

Super Key Columns का वह Combination है जो टेबल की किसी भी Row को Unique तरीके से पहचान सकता है। एक Table में कई Super Key हो सकती हैं। वास्तव में, Candidate Key और Primary Key, Super Key का ही हिस्सा होती हैं।

6:- Candidate key

Candidate key वह key होती है जो primary key बनने के लिए योग्य होती है। एक table में कई candidate keys हो सकती हैं, लेकिन उनमें से एक को primary key चुना जाता है।

Keys को याद रखने का आसान तरीका (Table)

Keyमुख्य काम
Primary Keyहर record को unique पहचान देना, इसमें NULL नहीं होता
Foreign Keyदो tables को आपस में जोड़ना और relation बनाना
Candidate KeyPrimary Key बनने के लिए available सभी विकल्प
Super Keyऐसे सभी columns का सेट जो record को uniquely identify कर सकते हैं
Composite Keyएक से ज्यादा columns मिलकर unique पहचान देते हैं
Artificial Keysystem द्वारा बनाई गई extra unique ID (जैसे ID number)

NOTE:- आपको “Types of Keys in DBMS in Hindi” पोस्ट कैसी लगी आप हमें कमेंट के माध्यम से अवश्य बतायें। हमें आपके कमेंट्स का बेसब्री से इन्तजार रहता है। अगर आपका कोई सवाल या कोई suggestions है तो हमें बतायें हम उसको एक या दो दिन के अंदर यहाँ प्रकाशित करेंगे और हाँ पोस्ट Share जरूर करें।

40 thoughts on “DBMS में Keys क्या हैं और उनके प्रकार (Types of Keys in DBMS in Hindi)”

    • Thanks anurag …you can subscribe the site by putting email. Or just like our Facebook page. You will get new posts information.

      Reply
  1. i found every where but that keys concept was not any where .I realy like this post and i fully understood the concept much better than other websites

    Reply
  2. Such a good notes , simple language and best to understand…..
    Thanks alot sir ji…
    Please add another subject (c,c++,ds)notes for helping students..

    Reply

Leave a Comment