Is setting the foreign key as surrogate of the parent table expense ?
Since I have to join that parent /reference table to show the natural key.
But why it is the best to set the foreign key as surrgate for referencing table.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is expensive in a sense that you’d need a JOIN in some situations where it would not be necessary with the natural key (as you already noted). Also, natural keys usually play better with clustering, and are sometimes necessary for correctly modelling diamond-shaped dependencies.
On the other hand, using a “skinnier” surrogate key can save some space and simplify updating (especially when there are several levels of FKs).
Neither approach is absolutely “better” – It’s a matter of compromise.