In database management systems, a Primary Key is a candidate key that is chosen by the database designer to serve as the main unique identifier for rows in a table. It is the single most important key in the relational model because it is used extensively for indexing, referencing, and enforcing data integrity.

Every table in a relational database is expected to have exactly one primary key, which may consist of a single attribute or multiple attributes (composite primary key). The primary key is the concrete realization of the uniqueness constraints defined by candidate keys.

What is a Primary Key?

A Primary Key is a candidate key that satisfies the following conditions:

  • It uniquely identifies each row in the table.

  • It does not allow NULL values (the primary key column(s) must always have a value).

  • It is chosen from the available candidate keys of the table.

  • It is used by the DBMS to organize physical storage and create default indexes for fast access.

For example, in a STUDENT table, if both Roll_No and Email are candidate keys, the designer might choose Roll_No as the primary key because it is compact and business‑driven.

Rules for Primary Keys

  • Uniqueness: No two rows can have the same primary key value.

  • Non‑null: Primary key attributes must not contain NULL values.

  • Immutability (recommended): Ideally, the primary key value should not change once assigned, to avoid cascading updates in related tables.

  • One per table: A table has only one primary key, though that key may be composite.

Example with a Primary Key

Consider a STUDENT table:

Roll_NoEmailNameBranchCGPA
101aman@email.comAmanCSE8.5
102riya@email.comRiyaECE7.9
103kunal@email.comKunalME8.1

Assume:

  • {Roll_No} is a candidate key.

  • {Email} is also a candidate key.

If the designer chooses Roll_No as the primary key, then:

  • Roll_No must be unique and not null.

  • The DBMS can use Roll_No for indexing and efficient searches.

  • Related tables (for example, ENROLLMENT) can use Roll_No as a foreign key to reference this table.

Why Primary Keys Matter in Design?

Primary keys are crucial because:

  • They provide a reliable way to identify each row uniquely.

  • They form the basis for foreign keys and table relationships.

  • They enable fast retrieval and indexing operations.

  • They help enforce referential integrity in relational databases.

For beginners, understanding primary keys as the chosen minimal unique identifier from the candidate keys makes it easier to see how tables are connected and how data integrity is maintained.

Summary

A Primary Key in DBMS is the chosen candidate key that serves as the main unique identifier for rows in a table. It must be unique and non‑null and is used for indexing, referencing, and enforcing data integrity. Primary keys are fundamental to relational database design and are the backbone of relationships between tables.