Tom Lane <[EMAIL PROTECTED]> writes:

> Greg Stark <[EMAIL PROTECTED]> writes:
> > This could hurt if they ever reuse an old previously retired postal code,
> > which isn't an entirely impossible case. As far as I know it hasn't happened
> > yet though.
> One would suppose that the guys who are in charge of this point at
> Canada Post consider the postal code to be their primary key, and
> are no more eager to reuse one than you are to see it reused.

Well, they may eventually be forced to. For the same sort of hierarchic issue
that causes the "shortage" of IPv4 address space even though there's far less
than 4 billion hosts online.

But as far as I can see today the only postal codes that are being retired are
rural areas that are being developed and have blocks of codes assigned instead
of having a single broad code.

> Basically this comes down to "I'm going to use some externally supplied
> primary key as my primary key.  Do I trust the upstream DBA to know what
> a primary key is?"

Well there's another issue here I think. Often people see something that looks
unique and is clearly intended to be a primary key and think "aha, nice
primary key" but they miss a subtle distinction between what the external
primary key represents and what their data model is tracking.

The typical example is social security numbers. SSNs are a perfectly
reasonable primary key -- as long as you're tracking Social Security accounts,
not people. Most people in the US have exactly one SS account, so people often
think it looks like a primary key for people. In fact not everyone has a
Social Security account (aliens who have never worked in the US, or for that
matter people who have never been in the US) and others have had multiple
Social Security accounts (victims of identity theft).

Another example that comes to mind is the local telephone company. When I
changed my phone number they created a new account without telling me, because
their billing system's primary key for accounts is... the phone number. So all
my automated bill payments started disappearing into the black hole of the old
account and my new account went negative. I wonder what they do for customers
who buy services from them but don't have a telephone line.


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to