Home
Schema - Do you create primary key on your tables?
  v3.0 Posted at 8/01/2020 2:43 PM by Christian Morford-Waite
​​When you specify a PRIMARY KEY constraint for a table, SQL Server enforces data uniqueness by creating a unique index for the primary key columns. This index also permits fast access to data when the primary key is used in queries.

Although, strictly speaking, the primary key is not essential - we recommend all tables have a primary key (except tables that have a high volume of continuous transactions). 

Figure: Bad Example - Table missing primarykey
Figure: Good Example - Table with primary key

Legacy: 

Especially, when you have a client like Access, it would help you to avoid the problems.​​

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments: