Keys in DBMS

Consider Student(roll_no, aadhaar, email, name, dept).

KeyDefinitionExample
Super keyAny set of attributes that uniquely identifies a tuple{roll_no}, {roll_no, name}, {email, dept}
Candidate keyA minimal super key{roll_no}, {aadhaar}, {email}
Primary keyThe candidate key chosen by the designer; unique and NOT NULLroll_no
Alternate keyCandidate keys not chosen as primaryaadhaar, email
Foreign keyAttribute referring to the primary key of another tabledept → Department(dept_id)
Composite keyKey made of two or more attributes(roll_no, course_id)
Surrogate keySystem-generated key with no business meaningauto-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

Text
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