From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: D'Arcy J.M. Cain <darcy@druid.net>
Cc: David Clarke <pigwin32@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Alternative to serial primary key
Date: Fri, 7 Jul 2006 15:22:57 +0300 (EEST)
Message-ID: <Pine.LNX.4.44.0607071513540.24785-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <20060707073325.926f601f.darcy@druid.net>
O D'Arcy J.M. Cain Ýãñáøå óôéò Jul 7, 2006 :
> On Fri, 7 Jul 2006 19:37:15 +1200
> "David Clarke" <pigwin32@gmail.com> wrote:
> > > And even given all of that, I would probably still use serial.
> > Because?
>
> Simplicity. Cleanliness.
>
> > > Danger, Will Robinson. The phrase "regenerate my primary key"
> > > immediately raises the hairs on the back of my neck. If the primary
> > > key can ever change, you have a broken schema.
> >
> > Perhaps my choice of words was somewhat hasty. A serial is totally
> > divorced from the data it represents whereas a md5 hash is (for my
> > purposes) unique, stable, verifiable, and simple.
>
> It's not that I think that the primary key should never have meaning in
> the database (I use the two letter country code as the PK in my country
> table for example) I just think that it's dangerous ground and should
> be tread very carefully.
I think some similar "artificial vs natural keys" discussion was active
some months ago in the -sql list.
I say, 99% of the cases use serials for Primary Keys.
They do that they are designed for, and they are robust,
and ultra reliable.
If someone whishes, then he/she can enforce some
Unique Keys as well, on the natural columns.
So as a rule of thumb, i do system work (PKs,FKs) with artificial columns,
and human work (UKs) (read: prone to change!!!) with natural columns.
In my experience, using natural columns for (PKs,FKs) has always resulted
in a lost weekend trying to convert to artificial keys.
>
> However, I join others in applauding you for your efforts to investigate
> this so deeply. You may wind up coming out of this with something
> interesting, even if it isn't what you went in looking for.
>
>
--
-Achilleus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: achill@matrix.gatewaynet.com, darcy@druid.net, pigwin32@gmail.com
Subject: Re: Alternative to serial primary key
In-Reply-To: <Pine.LNX.4.44.0607071513540.24785-100000@matrix.gatewaynet.com>
References: <20060707073325.926f601f.darcy@druid.net> <Pine.LNX.4.44.0607071513540.24785-100000@matrix.gatewaynet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox