What Makes a Good Primary Key?

Look for these features when you select a primary key.

Michelle A. Poolet

September 18, 2001

1 Min Read
Database design strucutre illustration

Good primary keys are essential to good database design. They let you query and modify each table row individually without changing other rows in the same table. When you evaluate candidates for a table's primary key, follow these rules:

  • The primary key should consist of one column whenever possible.

  • The name should mean the same 5 years from now as it does today.

  • The data value should be non-null and remain constant over time.

  • The data type should be either an integer or a short, fixed-width character.

  • If you're using a character data type, the primary key should exclude differential capitalization, spaces, and special characters, which might be difficult to remember.

For additional information about choosing a good primary key, see SQL by Design, "How to Choose a Primary Key," April 1999.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like