X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 8891E9FB1D5 for ; Fri, 7 Jul 2006 09:09:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 38105-03 for ; Fri, 7 Jul 2006 09:09:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from matrix.gatewaynet.com (host2.dynacom.ondsl.gr [62.103.35.210]) by postgresql.org (Postfix) with ESMTP id 437629FA64B for ; Fri, 7 Jul 2006 09:09:06 -0300 (ADT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id k67CMvVa024899; Fri, 7 Jul 2006 15:22:57 +0300 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id k67CMvdZ024895; Fri, 7 Jul 2006 15:22:57 +0300 Date: Fri, 7 Jul 2006 15:22:57 +0300 (EEST) From: Achilleus Mantzios To: "D'Arcy J.M. Cain" cc: David Clarke , Subject: Re: Alternative to serial primary key In-Reply-To: <20060707073325.926f601f.darcy@druid.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/93 X-Sequence-Number: 25667 O D'Arcy J.M. Cain έγραψε στις Jul 7, 2006 : > On Fri, 7 Jul 2006 19:37:15 +1200 > "David Clarke" 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