←back to thread

121 points b-man | 1 comments | | HN request time: 0.213s | source
Show context
mrkeen ◴[] No.44026549[source]
> Principle of Essential Denotation (PED): A relation should be identified by a natural key that reflects the entity’s essential, domain-defined identity — not by arbitrary or surrogate values.

  create table citizen (
    national_id national_id primary key,
    full_name text);
Is national_id really a natural key, or is it someone else's synthetic key? If so, should the owner of that database have opted for a natural key rather than a synthetic key?

More arguments for synthetic over natural keys: https://blog.ploeh.dk/2024/06/03/youll-regret-using-natural-...

replies(3): >>44026597 #>>44026611 #>>44027242 #
rawgabbit ◴[] No.44026611[source]
I was going to comment on this. Natural keys sound like a good idea and they should enforced maybe by using a unique constraint.

Natural keys are important. But the real world and the databases that represent them are messy. People’s identities get stolen. Data entry mistakes and integration between systems fail and leave the data in a schizophrenic state.

In my experience I find arguments about natural keys unproductive. I usually try to steer the conversation to the scenarios I mentioned above. Those who listen to me will have a combination of synthetic and natural keys. The first is used to represent system state. The second is used to represent business processes.

replies(2): >>44026657 #>>44030408 #
arkh ◴[] No.44030408[source]
Natural key for people: let's use your DNA map.
replies(1): >>44087669 #
1. mrankin ◴[] No.44087669[source]
It wasn’t me. I wasn’t there. It must have been my evil twin brother. — Thomas Dolby