Schema - Do you create primary key on your tables?
Updated by Babanazar Kamyljanov [SSW] 11 months ago. See history
123
<introEmbed
body={<>
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).
<imageEmbed
alt="Image"
size="large"
showBorder={false}
figureEmbed={{
preset: "badExample",
figure: 'Bad Example - Table missing primarykey',
shouldDisplay: true
}}
src="/uploads/rules/create-primary-key-on-your-tables/sql-table-without-primary-key.png"
/>
<imageEmbed
alt="Image"
size="large"
showBorder={false}
figureEmbed={{
preset: "goodExample",
figure: 'Good Example - Table with primary key',
shouldDisplay: true
}}
src="/uploads/rules/create-primary-key-on-your-tables/sql-table-with-primary-key.png"
/>
**Legacy:**
Especially, when you have a client like Access, it would help you to avoid the problems.
</>}
/>
Related rules
Need help?
SSW Consulting has over 30 years of experience developing awesome software solutions.