Google

Friday, April 18, 2008

Selecting a Primary Key (PK)

There are at least two criteria to consider in selecting a primary key (PK) column or columns. By the way a PK consisting of two or more columns is called a composite primary key.
So here are the criteria:
  • The values in the PK column should be unique.  There should be no duplication of values in a column.  In the case of a composite PK, the combination of values should be unique.
  • A PK column should not contain a null value (blank value).
A primary key is very useful in relating fields from several tables.  It serves as a unique identifier of a record in a table.

Another application of PK is in record searching.  A PK helps in easy finding of specific record/s in a table or group of tables.

No comments: