[quote=“Mittineague, post:11, topic:197440, full:true”]So if one were to use id alone, how would you prevent things like “St. Paul”, “Saint Paul” from happening?
[/quote]the id wouldn’t prevent that
if you’re using a surrogate key, though, you would ~definitely~ also want a UNIQUE constraint on the natural key, in this case city + state
so the UNIQUE constraint prevents “Saint Paul, MN” from being entered twice
so right there, that puts paid to the notion that “natural keys increase the risk of obscure bugs for very little benefit” which is somebody’s opinion, but only an opinion
however, neither the id with UNIQUE constraint on the natural key, nor the natural PK, will prevent “Saint Paul, MN” and “St Paul, MN” from being entered
and think about this – under what circumstances would you need to change the natural PK?
well, there can be only two possibilities –
- a city changes its name
- a city moves to another state
all you surrogate key fans can now explain how the surrogate key makes either of the above scenarios easier to deal with… take as long as you like
me, i prefer the natural FK in this scenario – nobody should try to expand this discussion to social security numbers – each case should be dealt with on its own merits
in this scenario, any time you need to search the junction table (e.g. find all territories for a particluar consultant), you need one less join – there’s a solid advantage right there