Re: Primary Key - Mailing list pgsql-general

From Tom Lane
Subject Re: Primary Key
Date
Msg-id 11357.1195837664@sss.pgh.pa.us
Whole thread Raw
In response to Re: Primary Key  (Ron Johnson <ron.l.johnson@cox.net>)
List pgsql-general
Ron Johnson <ron.l.johnson@cox.net> writes:
> On 11/23/07 03:33, Peter Childs wrote:
>> The worse thing I meet is people who think primary keys need to be
>> integer single field unique serial fields
>>
>> 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.

> I wouldn't trust plate number to be unique over time, since the
> format "ABC 123" only has a capacity of 17,576,000 vehicles.

There's a worse problem than that: what if you find out that you
mis-entered the value?  Now you have to change the record's primary key
in order to stay consistent with the real world.  Which is exactly what
a primary key should never have to do, at least in the opinion of those
who recommend synthetic primary keys.

            regards, tom lane

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] AutoVacuum Behaviour Question
Next
From: Tom Hart
Date:
Subject: Re: best way to handle enum type