Re: surrogate vs natural primary keys

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: Seb <spluque(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: surrogate vs natural primary keys
Date: 2008-09-15 22:45:08
Message-ID: dcc563d10809151545r70d7d2a7j25931d7557dd88f3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Sep 15, 2008 at 4:02 PM, Seb <spluque(at)gmail(dot)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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Seb 2008-09-15 22:56:31 Re: surrogate vs natural primary keys
Previous Message Seb 2008-09-15 22:02:05 surrogate vs natural primary keys