Re: Alternative to serial primary key

Поиск
Список
Период
Сортировка
От Achilleus Mantzios
Тема Re: Alternative to serial primary key
Дата
Msg-id Pine.LNX.4.44.0607071513540.24785-100000@matrix.gatewaynet.com
обсуждение исходный текст
Ответ на Re: Alternative to serial primary key  ("D'Arcy J.M. Cain" <darcy@druid.net>)
Список pgsql-sql
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



В списке pgsql-sql по дате отправления:

Предыдущее
От: Michael Glaesemann
Дата:
Сообщение: Re: Update from join
Следующее
От: "Weber, Johann (ISS Kassel)"
Дата:
Сообщение: Atomar SQL Statement