What is the primary key?

Within a given relation, a set of one or more attributes having values that are unique within the relation and thus can uniquely identify that tuple, is said to be the primary key of the relation.

1 min read

Within a given relation, a set of one or more attributes having values that are unique within the relation and thus can uniquely identify that tuple, is said to be the primary key of the relation.

A Primary Key is a set of one or more attributes that can uniquely identify tuples within the relation.



Every relation does have a primary key. In our sample database, SuppNo is the primary key for Suppliers as it contains a unique value for each tuple in the relation. Similarly, ItemNo is the primary key for Items, and the combination of SuppNo and ItemNo is the primary key for the Shipments relation.

In some tables, a combination of more than one attribute provides a unique value for each row. In such tables, the group of these attributes is declared as the primary key. In such cases, the primary key consists of more than one attribute, it is called composite-primary-key.
The primary key is nonredundant i.e. it does not have duplicate values in the same relation.
The non-primary-key attributes of a table can be referred to as non-key attributes.


What is the primary key in MySQL?

Within a given relation, a set of one or more attributes having values that are unique within the relation and thus can uniquely identify that tuple, is said to be the primary key of the relation.

1 min read

Primary key in DBMS

Within a given relation, a set of one or more attributes having values that are unique within the relation and thus can uniquely identify that tuple, is said to be the primary key of the relation.

1 min read