Keys in DBMS
Consider Student(roll_no, aadhaar, email, name, dept).
| Key | Definition | Example |
|---|---|---|
| Super key | Any set of attributes that uniquely identifies a tuple | {roll_no}, {roll_no, name}, {email, dept} |
| Candidate key | A minimal super key | {roll_no}, {aadhaar}, {email} |
| Primary key | The candidate key chosen by the designer; unique and NOT NULL | roll_no |
| Alternate key | Candidate keys not chosen as primary | aadhaar, email |
| Foreign key | Attribute referring to the primary key of another table | dept → Department(dept_id) |
| Composite key | Key made of two or more attributes | (roll_no, course_id) |
| Surrogate key | System-generated key with no business meaning | auto-increment id |
RelationshipEvery candidate key is a super key, but not every super key is a candidate key.
Finding Candidate Keys with Attribute Closure
R(A, B, C, D), FDs: A → B, B → C, C → D
A+ = {A} → add B (A→B) → add C (B→C) → add D (C→D)
A+ = {A, B, C, D} = all attributes ⇒ A is a candidate key
A never appears on a right-hand side, so every key must contain A
⇒ A is the only candidate key.
Quick Check
A minimal super key is called a…
Track your progress through the DBMS course