Re: Primary Key

Поиск
Список
Период
Сортировка
От Csaba Nagy
Тема Re: Primary Key
Дата
Msg-id 1195815618.27060.104.camel@PCD12478
обсуждение исходный текст
Ответ на Re: Primary Key  (Martijn van Oosterhout <kleptog@svana.org>)
Ответы Re: Primary Key
Список pgsql-general
On Fri, 2007-11-23 at 11:37 +0100, Martijn van Oosterhout wrote:
> On Fri, Nov 23, 2007 at 09:33:13AM +0000, Peter Childs wrote:
> > I tend to agree that primary keys should be single fields if they need to be
> > referenced but should also be natural if at all possible. ie use car number
> > plates rather than some serial int.
>
> Car number plates are unique over time? I didn't think so...

I'm not sure how it is in the US, but here in Germany I just reused a
car plate from the owner it had before me... so now the plate is
uniquely associated at most with the car, not the owner... and I'm
pretty sure that's not unique either.

And what do you do when the things shift meaning in your natural key ?
Cause that's a very common thing to happen to natural keys. And suddenly
what was unique becomes not unique anymore... and the headaches begin...

You're better off using synthetic keys for references between tables,
and you can still keep your natural keys for lookup, just don't use them
as unique join criteria, only search/filter criteria.

Cheers,
Csaba.



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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Primary Key
Следующее
От: Dragan Zubac
Дата:
Сообщение: Transaction question