Re: surrogate vs natural primary keys

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: surrogate vs natural primary keys
Дата
Msg-id dcc563d10809151545r70d7d2a7j25931d7557dd88f3@mail.gmail.com
обсуждение исходный текст
Ответ на surrogate vs natural primary keys  (Seb <spluque@gmail.com>)
Ответы Re: surrogate vs natural primary keys  ("Richard Broersma" <richard.broersma@gmail.com>)
Список pgsql-sql
On Mon, Sep 15, 2008 at 4:02 PM, Seb <spluque@gmail.com> wrote:
> Hi,
>
> I've been reading several articles on this hotly debated issue and still
> can't find proper criteria to select one or the other approach for the
> database I'm currently designing.  I'd appreciate any pointers.  Thanks.

You'll find lots of arguments from both sides, some more strident than
others.  In most big transactional systems you'll find surrogate keys
used for performance reasons, as well as design choices.  for
instance, when you book a flight with an airline, you'll get a locator
code like A89JK3 that is unique to any other locator code in the
system.  Sure, you could make a natural key of first name, last name,
address, phone number, flight number, departure / arrival and day and
time, but there's no way that's going to perform as well as a single
char(6).

The problem with natural keys is that you can never be sure they won't
change on you.  I like using them, but have been caught out on many
occasions where things changed halfway through development and
required a lot of redesign.

I think this question is a lot like "how large should I set
shared_buffers?"  There's lots of different answers based on how you
are using your data.


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

Предыдущее
От: Seb
Дата:
Сообщение: surrogate vs natural primary keys
Следующее
От: Seb
Дата:
Сообщение: Re: surrogate vs natural primary keys