[
the cutting edge ]
G'Day Developers!
Now this is a controversial one. Which one do you use?
- A "Natural" (or "Intelligent") key is actual data
- Surname, FirstName, DateOfBirth
- An "Acquired Surrogate" (or "Artifical" or "System Generated") key is NOT derived from data eg.
Autonumber
- eg. ClientID 1234
- eg. ClientID JSKDYF
- eg. ReceiptID 1234
- A "Derived Surrogate" (or "User Provided") key is indirectly derived from data eg. Autonumber
- eg. ClientID SSW (for SSW)
- eg. EmpID AJC (for Adam Jon Cogan)
- eg. ProdID CA (for Code Auditor)
The problems with Natural Keys:
- Because they have a business meaning, if that meaning changes (eg. they change their surname),
then that
value NEEDS to changed. Changing a value with data is a little hard - but a lot easier with Cascade
Update.
- The main problem is that the key is large and combined and this needs to be used in all joins
The Problem with Acquired Surrogate Keys:
- A surrogate key has no meaning to a user
- It always requires a join when browsing a child table eg. The InvoiceDetail table
The Problem with Derived Surrogate
- The user needs to enter a unique value
- Because they have a business meaning, if that meaning changes (eg. they change their company
name),
then that value MAY NEED to changed. Changing a value with data is a little hard - but a lot easier
with
Cascade Update
- More likely to have a problem with Merge Replication
So our recommendations are:
Sample code for the SSW Derived Surrogate:
Cheers until next time,
Adam
SSW Chief Architect and Microsoft Regional Director, Australia
Got a comment for Adam?
6164616d636f67616e407373772e636f6d2e6175
|