Keys in DBMS (हिंदी) in Hindi

Key, dbms में एक या एक से अधिक कॉलम columns का सेट है जो की table में हर एक पंक्ति (row) को विशिष्ट (unique) रूप से पहचानता है। प्राइमरी key ensure करती है कि किसी भी दो पंक्ति (rows) में सामान values न हो।

  • Keys का उपयोग DBMS में डाटा सर्च करने के लिए करते है।
  • Keys Relational DBMS एक Basic लेकिन बहुत महत्वपूर्ण Concept, जिसका उपयोग पड़ते समय आय चाहे न आये लेकिन जब डेटाबेस डिज़ाइन करते है तब जरूर आता है।

Types of Keys

Primary Key

Primary Key किसी टेबल में एक या एक से अधिक कॉलम columns का सेट है जो की table में हर एक पंक्ति (row) को विशिष्ट (unique) रूप से पहचानता (identifies) है। 

  • Uniqueness: प्राथमिक key कॉलम में प्रत्येक मान अद्वितीय होना चाहिए।
  • Non-null: Primary key columns के पास NULL values नहीं होनी चाहिए।
  • Single table constraint: हर एक टेबल के पास केवल और केवल एक प्राइमरी key होनी चाहिए।

यहाँ पर प्राइमरी key studentid है एवं ईमेल एक candidate  key है। 

StudentIDNameAgeMajorEmail
1Alice Smith20Computer Science
alice@example.com
2Bob Johnson22Mathematics
bob@example.com
3Carol Davis21Physics
carol@example.com

Super Key

Super key एक या अधिक columns का एक सेट है, जो सामूहिक रूप से, किसी तालिका में एक पंक्ति को विशिष्ट रूप से पहचान सकती है। सभी candidate keys, super key हैं, लेकिन सभी super keys candidate keys नहीं हैं।

Table – Students

StudentIDNameAgeMajorEmailPhoneNumber
1Alice Smith20Computer Sciencealice@example.com1234567890
2Bob Johnson22Mathematicsbob@example.com2345678901
3Carol Davis21Physicscarol@example.com3456789012

Example: Students table में, {StudentID}, {StudentID, Email}, और {StudentID, PhoneNumber}सभी super keys हैं।

    Foreign Key

    Foreign key, एक या एक से अधिक columns का  combination है, जो दो टेबल के बीच में रिलेशनशिप एस्टब्लिश स्थापित करती है।   

      • Can be null – Foreign key कॉलम में NULL value हो सकते हैं। 

    Table – Enrollments

    EnrollmentIDStudentIDCourseID
    1011501
    1022502
    1033503
    1041504

    Foreign Key: यहाँ पर StudentID foreign key है। 

    Candidate Key

    एक candidate के एक कॉलम या कॉलम कॉम्बिनेशन है जो की uniquely हर row को, टेबल में। एक टेबल के पास multiple  candidate keys हो सकती है, इनमे से एक हो प्राइमरी key चुना जाता है।

    StudentIDNameAgeMajorEmail
    1Alice Smith20Computer Science
    alice@example.com
    2Bob Johnson22Mathematics
    bob@example.com
    3Carol Davis21Physics
    carol@example.com

    Composite Key

    एक Composite key एक कॉलम या कॉलम कॉम्बिनेशन है जो की row uniquely identify करता  टेबल में। यह की use होती है – जब single sufficient नहीं होता है हर एक row को identify करने के लिए।

    StudentIDCourseIDGrade
    1501A
    2502B
    3503A
    1504B

    Composite Key: {StudentID, CourseID} (The combination of StudentID and CourseID uniquely identifies each enrollment record).

    Unique Key

    एक unique key, एक कॉलम या कॉलम कॉम्बिनेशन है जो की यह सुनिश्चित करता है की टेबल में सभी rows यूनिक हो। 

    EmployeeIDNameEmailPhoneNumber
    1John Millerjohn@example.com1234567890
    2Sarah Brownsarah@example.com2345678901
    3Emily Clarkemily@example.com3456789012
    • Primary Key: EmployeeID
    • Unique Keys: Email, PhoneNumber (Both Email and PhoneNumber columns unique vlaues होनी चाहिए पूरी टेबल में)

    References

    PDF Notes Link

    Leave a Comment

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

    Scroll to Top