Keys in DBMS | Types of Keys Explained for Students

 

✅ What is a Key?

A Key is a column or field in a table that helps to uniquely identify each record in the table.
It helps us to find out which record is different from others.

📝 In simple words:
Just like a student’s Roll Number is unique — a Key helps identify each data row uniquely in a table.


🧩 Why Are Keys Important?

  • To uniquely identify every row (record)

  • To prevent duplicate data

  • To create relationships between tables

  • To search data faster using queries


🔢 Types of Keys in DBMS

Let’s understand the different types of keys used in a DBMS:


1. 🎯 Primary Key

A Primary Key is the main key that uniquely identifies each record in a table.

  • It cannot be NULL

  • No two rows can have the same Primary Key

📌 Example: Roll Number, Employee ID


2. 🆔 Candidate Key

A Candidate Key is any column (or set of columns) that can be a Primary Key.

Among these, we select one as the Primary Key.

📌 Example: In a student table — both Roll Number and Aadhaar Number can be Candidate Keys.


3. 🌟 Super Key

A Super Key is any column or group of columns that can uniquely identify a record.

  • Every Primary Key is a Super Key,

  • But not every Super Key is a Primary Key.

📌 Example: {Roll Number}, {Roll Number + Name}


4. 🧩 Composite Key

A Composite Key is made up of two or more columns used together to identify a row.

📌 Example: {Student_ID, Course_ID}
Together they form a unique combination.


5. 🔐 Foreign Key

A Foreign Key is a key used to link two tables together.
It refers to the Primary Key of another table.

📌 Example:

  • In the Student Table: Student_ID (Primary Key)

  • In the Marks Table: Student_ID (Foreign Key)


6. 🕳️ Alternate Key

An Alternate Key is a Candidate Key that was not selected as the Primary Key.

📌 Example:

  • Roll Number (Primary Key)

  • Aadhaar Number (Alternate Key)


📝 Quick Summary Table

Key TypeWhat It Does
Primary KeyUniquely identifies each record
Candidate KeyEligible to become Primary Key
Super KeyAny column(s) that can uniquely identify data
Composite KeyTwo or more columns used as one key
Foreign KeyLinks one table to another
Alternate KeyCandidate Key not chosen as Primary Key

🎯 Final Words

Keys are one of the most important topics in DBMS.
They not only help to uniquely identify data, but also create relationships between tables.

We hope this post helped you understand Types of Keys in DBMS clearly. If you want, we can also make an infographic or student revision notes for this topic.


👉 Also Read:

  • [What is DBMS?]

  • [Types of Attributes in DBMS]

 

Keys in DBMS | Types of Keys Explained in Simple Language

✅ Key क्या होती है?

Key एक ऐसा कॉलम या फील्ड होती है जो टेबल में डाटा की पहचान करने के काम आती है।
यह हमें बताती है कि कौन-सा रिकॉर्ड यूनिक (अलग) है। Keys की मदद से ही हम दो एक जैसे दिखने वाले रिकॉर्ड्स के बीच अंतर कर सकते हैं।

📝 आसान भाषा में:
जैसे किसी स्टूडेंट का “Roll Number” यूनिक होता है — वैसे ही Key किसी भी डेटा रिकॉर्ड की पहचान करती है।


🧩 Keys क्यों जरूरी हैं?

  • टेबल में हर रिकॉर्ड को uniquely पहचानने के लिए

  • डुप्लिकेट डाटा से बचने के लिए

  • टेबल्स के बीच कनेक्शन (Relationship) बनाने के लिए

  • क्विक सर्च और क्वेरी के लिए


🔢 Types of Keys in DBMS (DBMS में Key के प्रकार)

अब जानते हैं DBMS में कितने प्रकार की Keys होती हैं:


1. 🎯 Primary Key

Primary Key वह Key होती है जो टेबल के हर रिकॉर्ड को unique पहचान देती है।

  • दो rows में एक जैसी Primary Key नहीं हो सकती

  • यह NULL नहीं हो सकती

📌 Example: Roll Number, Employee ID


2. 🆔 Candidate Key

Candidate Keys वे सभी कॉलम होते हैं जो टेबल में Primary Key बनने की क्षमता रखते हैं।

Primary Key उन्हीं में से एक होती है।

📌 Example: एक स्टूडेंट टेबल में Roll Number और Aadhaar Number — दोनों Candidate Key हो सकते हैं।


3. 🌟 Super Key

Super Key वो होती है जो टेबल के रिकॉर्ड को uniquely पहचान सके।

हर Primary Key एक Super Key होती है, लेकिन हर Super Key जरूरी नहीं कि Primary Key हो।

📌 Example: {Roll Number}, {Roll Number + Name} — दोनों Super Keys हो सकती हैं।


4. 🧩 Composite Key

जब हम एक से ज्यादा कॉलम को मिलाकर किसी row को uniquely पहचानते हैं, तब उसे Composite Key कहते हैं।

📌 Example: {Student_ID, Course_ID}

दोनों मिलकर एक यूनिक रिकॉर्ड बनाते हैं।


5. 🔐 Foreign Key

Foreign Key वह कॉलम होता है जो दूसरी टेबल की Primary Key से जुड़ा होता है।

यह दो टेबल्स के बीच रिलेशन बनाता है।

📌 Example:

  • Student Table में – Student_ID (Primary Key)

  • Marks Table में – Student_ID (Foreign Key)


6. 🕳️ Alternate Key

Candidate Keys में से जो Key Primary Key नहीं बनी, वो Alternate Key कहलाती है।

📌 Example:

  • Roll Number (Primary Key)

  • Aadhaar Number (Alternate Key)


📝 Short Summary Table

Key TypePurpose
Primary Keyहर रिकॉर्ड को uniquely पहचानना
Candidate KeyPrimary Key बनने योग्य कॉलम
Super KeyUnique पहचान देने वाला कोई भी कॉलम
Composite Keyदो या ज्यादा कॉलम मिलकर पहचान बनाएं
Foreign Keyदूसरी टेबल की Primary Key से कनेक्ट
Alternate KeyCandidate Key जो Primary Key नहीं बनी

🎯 Final Words

Keys DBMS का एक बहुत ही जरूरी और बेसिक कॉन्सेप्ट है। यह न केवल टेबल्स में डाटा को पहचानने में मदद करती है, बल्कि टेबल्स को आपस में जोड़ने का काम भी करती है।

उम्मीद है यह पोस्ट आपको DBMS Keys को अच्छे से समझने में मदद करेगी। अगर आप चाहें तो मैं इसके लिए एक इन्फोग्राफिक या छात्रों के लिए क्विक नोट्स भी बना सकता हूँ।

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top