What Is A Primary Key In A DBMS?


2 Answers

Sehar Suleman Profile
Sehar Suleman answered
Primary keys are used to uniquely identify rows in a relational database design. It usually comprises of a single table column, but may consist of a multiple columns as well. Each row in a table must have a distinct value (or a set of values) in the column marked as the primary key. It is possible for a table to have more than one column with unique values in the table, however only one primary key can be defined. Each column with distinct values is called a unique key.

It should be kept in mind that a unique key must have distinct values in all possible rows, not just the currently existing ones. The Social Security Number, ISBN on books etc are good examples of unique keys.

A primary key can be regarded as a special unique key. No row can have an empty value (called the NULL) in the primary key column, where as a unique key is allowed to hold a NULL.

Primary keys can be defined at the time of table creation or can be added in after the table has been created.

All unique keys, including the primary key can be referenced by other tables through foreign keys.

Answer Question