4) Which order of records (defined by the clustered key) is the best depends on how the table is used. The surrogate key is a good candidate (never changing, new values added at the end) but it doesn't mean that no other option is possible. If you want to learn how to use clustered indexes, read Effective Clustered Indexes, for instance.
PrimaryIndex /clusteredIndex values vs surrogate key
Hi Martin,
1. What do you mean rename primary key? If i changed the content of primary key like adding a new field or replacing one, why would i rename it? Sorry i didn't understand?
2. And by natural key you mean allow duplicate No index?
3. You said surrogate key is better than combination of dataAreaId and another field. What if the table has save data per company as No. Would surrogate key still be better? And why?
4. Just to make sure, your explanation also for clustered index? I mean surrogate key is always better?
Martin Dráb230,466Most Valuable Professional
on at
PrimaryIndex /clusteredIndex values vs surrogate key
There are two main reasons for using surrogate keys:
Using a single numeric field is more efficient than using something like a combination of DataAreaId and another string field.
You don't ever need to change the surrogate key, therefore you don't have to deal with all the problems with "Rename primary key". When needed, you'll change the natural key.
The reason why tables like CustTable don't use surrogate keys is because they're created years before surrogate keys where added to Dynamics AX.
PrimaryIndex /clusteredIndex values vs surrogate key
It's recommend to use the surrogate key there and use a natural key as the replacement key.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.