database - surrogate keys as foreign key -


is setting foreign key surrogate of parent table expense ?

since have join parent /reference table show natural key.

but why best set foreign key surrgate referencing table.

it expensive in sense you'd need join in situations not necessary natural key (as noted). also, natural keys play better clustering, , necessary correctly modelling diamond-shaped dependencies.

on other hand, using "skinnier" surrogate key can save space , simplify updating (especially when there several levels of fks).

neither approach absolutely "better" - it's matter of compromise.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -