Re: Primary Key

From: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Peter Childs <peterachilds(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Primary Key
Date: 2007-11-23 11:00:18
Message-ID: 1195815618.27060.104.camel@PCD12478
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2007-11-23 at 11:37 +0100, Martijn van Oosterhout wrote:
> On Fri, Nov 23, 2007 at 09:33:13AM +0000, Peter Childs wrote:
> > I tend to agree that primary keys should be single fields if they need to be
> > referenced but should also be natural if at all possible. ie use car number
> > plates rather than some serial int.
>
> Car number plates are unique over time? I didn't think so...

I'm not sure how it is in the US, but here in Germany I just reused a
car plate from the owner it had before me... so now the plate is
uniquely associated at most with the car, not the owner... and I'm
pretty sure that's not unique either.

And what do you do when the things shift meaning in your natural key ?
Cause that's a very common thing to happen to natural keys. And suddenly
what was unique becomes not unique anymore... and the headaches begin...

You're better off using synthetic keys for references between tables,
and you can still keep your natural keys for lookup, just don't use them
as unique join criteria, only search/filter criteria.

Cheers,
Csaba.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dragan Zubac 2007-11-23 11:31:59 Transaction question
Previous Message Martijn van Oosterhout 2007-11-23 10:37:42 Re: Primary Key