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:
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.
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 .
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.
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.