What do you mean by a key to the relation? Explain the differences between super key, candidate key and primary key.

February 1, 2024 · By Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

The context of databases and relational database management systems (RDBMS), a “key” in a relation refers to a set of one or more attributes (columns) that can uniquely identify a tuple (row) in that relation. Keys play a crucial role in maintaining the integrity and structure of a relational database.

Difference between Super key, Candidate key and Primary key:

FeatureSuper KeyCandidate KeyPrimary Key
DefinitionAn attribute or set of attributes that uniquely identifies all attributes in a relation.A minimal set of super key.A minimal set of attributes that uniquely identifies rows in a relation.
All are Super KeysYesYesNo
Null ValuesCan be nullCan be nullCannot be null
Number of KeysAny number of super keys can exist.Number of candidate keys is less than super keys.Number of primary keys is less than candidate keys.
Example (from Fig. 1.23.1)(Registration), (Vehicle_id), (Registration, Vehicle_id), (Registration, Vehicle_id, Make), etc.(Registration, Vehicle_id)(Registration)
Diagram:

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion