Re: Primary Key - Mailing list pgsql-general

From Csaba Nagy
Subject Re: Primary Key
Date
Msg-id 1195815618.27060.104.camel@PCD12478
Whole thread Raw
In response to Re: Primary Key  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Primary Key
List 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.



pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Primary Key
Next
From: Dragan Zubac
Date:
Subject: Transaction question