Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What does PK and index do for a table?
Message
From
22/10/2018 12:49:32
 
 
To
20/10/2018 17:52:10
General information
Forum:
Microsoft SQL Server
Category:
Database design
Miscellaneous
Thread ID:
01662673
Message ID:
01662714
Views:
41
>Usually, a table row should an identifier that distinguishes it from the other rows in the table.
>If you already have a unique identifier for the row that is not the identity column eg. invoice number in an invoice table, there is no technical benefit from having an identity column.


Well, there is a technical benefit to surrogate keys based on a four-byte integer, as opposed to a 25 character alphanumeric.

In a large data warehouse table utilizing some of the Microsoft in-memory technology, integers compress and scale as vectors better than alphanumerics - better compression, better for the buffer pool.

Yes, that's nearly a niche feature, but in some cases it can be very helpful.

I generally don't use a business key as the primary key (though it can be a candidate key sometimes). Usually I have an identity surrogate as the key. Where that can help is if you're storing flat versions of a row (like a single Product SKU that has gone through 3 changes in four years, and the business wants to track sales associated with each version of the SKU.
Previous
Reply
Map
View

Click here to load this message in the networking platform