Re: Surrogate keys (Was: enums)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Glaesemann <grzm(at)myrealbox(dot)com>
Cc: "Dann Corbit" <DCorbit(at)connx(dot)com>, Leandro Guimarães Faria Corcete Dutra <leandro(at)dutra(dot)fastmail(dot)fm>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Surrogate keys (Was: enums)
Date: 2006-01-19 05:06:41
Message-ID: 10535.1137647201@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Michael Glaesemann <grzm(at)myrealbox(dot)com> writes:
> As far as I can tell, the only difference between your position,
> Dann, and Date and Darwen's, is that you think no natural key is
> immutable.

D&D's examples of "natural" keys are worth a second look though:

>> If a primary key exists for a collection that is known never to change,
>> for example social security number, student registration number, or
>> employee number, then no additional system-assigned UID is required.

The problem with SSN is that somebody other than you controls it.
If you are the college registrar, then you control the student's
registration number, and you don't have to change it. In fact, guess
what: you probably generated it in the same way as a surrogate key.

I'd argue that all of these are in reality the exact same thing as
a surrogate key --- from the point of view of the issuing authority.
But from anyone else's point of view, they are external data and you
can't hang your own database design on the assumption that they won't
change.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2006-01-19 06:07:56 Re: How to log full substituted queries?
Previous Message Trent Shipley 2006-01-19 04:49:38 Re: RAID-50

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2006-01-19 06:34:42 8.0.5 Bug in unique indexes?
Previous Message Bruce Momjian 2006-01-19 04:48:09 Re: pgxs/windows