From: | Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> |
---|---|
To: | "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net> |
Cc: | David Clarke <pigwin32(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Alternative to serial primary key |
Date: | 2006-07-07 12:22:57 |
Message-ID: | Pine.LNX.4.44.0607071513540.24785-100000@matrix.gatewaynet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
O D'Arcy J.M. Cain έγραψε στις Jul 7, 2006 :
> On Fri, 7 Jul 2006 19:37:15 +1200
> "David Clarke" <pigwin32(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2006-07-07 13:14:16 | Re: Atomar SQL Statement |
Previous Message | Michael Glaesemann | 2006-07-07 12:06:43 | Re: Update from join |