MySQL + SQL · Lesson 1

Dbms Keys Explained

All Keys in One Place

This page summarizes every key type in DBMS with a single clear example.

Every Key Type

KeyOne-line Meaning
Super keyAny unique-identifying column set
Candidate keyMinimal super key
Primary keyChosen main identifier (unique, not null)
Alternate keyCandidate keys not chosen primary
Foreign keyRefers to another table's primary key
Composite keyMade of multiple columns

School Example

students(roll_no PK, admission_no UNIQUE, name)
marks(roll_no FK, subject, score, PRIMARY KEY(roll_no, subject))
marks uses a COMPOSITE primary key (roll_no + subject) and roll_no is a FOREIGN key.

Summary

  • Keys: super, candidate, primary, alternate, foreign, composite.
  • Composite keys combine columns; foreign keys link tables.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

\n

💻 Live Code Editor

Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.
Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.

💻 Live Code Editor

Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें. Agar load na ho to naye tab mein kholें.