Re: surrogate vs natural primary keys - Mailing list pgsql-sql

From Scott Marlowe
Subject Re: surrogate vs natural primary keys
Date
Msg-id dcc563d10809151545r70d7d2a7j25931d7557dd88f3@mail.gmail.com
Whole thread Raw
In response to surrogate vs natural primary keys  (Seb <spluque@gmail.com>)
Responses Re: surrogate vs natural primary keys
List 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 by date:

Previous
From: Seb
Date:
Subject: surrogate vs natural primary keys
Next
From: Seb
Date:
Subject: Re: surrogate vs natural primary keys