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
| Key | One-line Meaning |
|---|---|
| Super key | Any unique-identifying column set |
| Candidate key | Minimal super key |
| Primary key | Chosen main identifier (unique, not null) |
| Alternate key | Candidate keys not chosen primary |
| Foreign key | Refers to another table's primary key |
| Composite key | Made 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.