Explorer
SQL

Primary Key vs Unique Key

Primary Key vs Unique Key

Both constraints enforce column uniqueness, but serve distinct roles in relational schema architecture.

Comparison Table

Attribute Primary Key Unique Key
Quantity per Table Exactly ONE Multiple allowed
Nullability NOT NULL (strictly forbidden) Allows NULLs (1 or multiple)
Default Index Clustered Index (InnoDB/MSSQL) Non-Clustered Index
Semantic Purpose Main entity identifier Secondary unique attributes
Foreign Key Target Primary target for FKs Valid target for FKs

Finished this lesson?

Mark this chapter complete to update your learning streak and unlock the next lesson.