Re: IS it a good practice to use SERIAL as Primary Key? - Mailing list pgsql-general

From Joshua D. Drake
Subject Re: IS it a good practice to use SERIAL as Primary Key?
Date
Msg-id 1164666996.6398.1.camel@localhost.localdomain
Whole thread Raw
In response to Re: IS it a good practice to use SERIAL as Primary Key?  (Scott Ribe <scott_ribe@killerbytes.com>)
Responses Re: IS it a good practice to use SERIAL as Primary Key?  (Scott Ribe <scott_ribe@killerbytes.com>)
List pgsql-general
On Mon, 2006-11-27 at 14:36 -0700, Scott Ribe wrote:
> > insert a new address, and update the users table to the new address_id
>
> Which changes the user's "primary key". My point was that having the address
> id be part of the primary key is wrong.

As I said, you don't *have* to do it that way. I was just giving an
example. You could just as easily grab the address id, insert that into
an archive table with a date stamp and then just update the address
itself. Thus *not* changing the "Primary Key".

Joshua D. Drake


>  Having it be a part of a key may be
> fine for many uses. But it's contrary to the notion of primary key that
> something that not only can, but will, change for many records should be
> part of the primary key. "Unique" and "primary" are *not* synonyms.
>
--

      === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive  PostgreSQL solutions since 1997
             http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate




pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: Re: IS it a good practice to use SERIAL as Primary Key?
Next
From: Tom Lane
Date:
Subject: Re: Unexpected sort order.