Why you may ask? Of course in SQL server you can use identity columns but if you need to rebuild the table from scratch then you have no guarantee that the same surrogate keys will be created for a given 'natural' key.
An alternative is to create a 'key' table that contains only a limited number of field, namely the primary (surrogate) key alongside the natural key of the table. This way, you can always create the table when necessary and are guaranteed to get the same surrogate keys.
In sql server you may need to disable any identity columns before the rebuild but can swicth it back on afterwards.
No comments:
Post a Comment
Would love to get feedback on any of my posts.