Keys are special attributes or combinations of attributes that uniquely identify a tuple in a relation. They help in establishing relationships between relations and ensuring data integrity. There are different types of keys, such as:

Candidate key

A candidate key is a minimal set of attributes that can uniquely identify a tuple in a relation . A relation can have more than one candidate key.

Primary key

A primary key is one of the candidate keys that is chosen to be the main identifier of a tuple in a relation. A relation can have only one primary key .

Alternate key

An alternate key is any candidate key that is not chosen as the primary key . An alternate key can also uniquely identify a tuple in a relation, but it is not used as the main identifier.

Foreign key

A foreign key is an attribute or a set of attributes in one relation that refers to the primary key of another relation. A foreign key establishes a link or a reference between two relations.

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo