3 ms·
> You are well advised to choose a primary key that is not only unique, but also never changes during the lifetime of a table row. This is because foreign key c
by zzzeek 5y ago
> You are well advised to choose a primary key that is not only unique, but also never changes during the lifetime of a table row. This is because foreign key constraints typically reference primary keys, and changing a primary key that is referenced elsewhere causes trouble or unnecessary work.
in one sense I agree with the author that things are generally just easier when you use surrogate primary keys, however they really should note here that the FOREIGN KEY constraint itself is not a problem at all as you can just use ON UPDATE CASCADE.
- dragonwriter 5y agoON UPDATE CASCADE avoids much developer impact, but it isn’t free and has (potentially quite large) performance impacts.