News for hackers. Stuff that matters.
Re:The problem with invariants is that they change over time by marcosdumay on Tuesday April 23, 2024 @10:05AM (#40132149)
I never found any kind of literature that clearly states that artificial keys are superior identifiers than natural ones.

Every material about relational data I've seen either just explains them, says they can be either natural or artificial, and leaves at that, or says there's some disagreement over what is better.

The unanimity exists only within field experts that apply the stuff. The theoreticians all disagree.

Re:The problem with invariants is that they change over time by CodesInChaos on Tuesday April 23, 2024 @12:21PM (#40133739)
I almost always use surrogate keys as primary keys (or a tuple of them, for join-tables). Natural keys are rarely as immutable and unique as we'd like.

Even ISO country codes can be problematic, for example we currently use XK for Kosovo, but it might get an official code at some point.

Re:The problem with invariants is that they change over time by bruce511 on Tuesday April 23, 2024 @03:17PM (#40136011)
It's less about literature, and more about experience.

Over the years just about every natural key I've seen ends up being either not-universal (-everyone- has a phone number right? Even that new-born baby?) Or not unique (phone numbers can be shared) or mutable (like people's names changing).

It's just so much easier to add a column and use a surrogate key. I prefer uuids because they are unique And immutable - properties I really appreciate in primary keys.

Re:The problem with invariants is that they change over time by abraae on Tuesday April 23, 2024 @04:52PM (#40137115)
It's an easy challenge. Just ask someone to name a natural key that will never change. They are as rare as rocking horse shit.