Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What does PK and index do for a table?
Message
De
22/10/2018 12:49:32
 
 
À
20/10/2018 17:52:10
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
01662673
Message ID:
01662714
Vues:
42
>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform