What Makes a Good Primary Key?
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.