Re: Primary Key

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Primary Key
Date: 2007-11-16 20:00:29
Message-ID: 20071116200029.GZ1955@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

( Fi Fie Foe Fum, I smell the blood of a religious war )

On Fri, Nov 16, 2007 at 01:03:23PM -0600, Ron Johnson wrote:
> On 11/16/07 12:54, Sam Mason wrote:
> > On Fri, Nov 16, 2007 at 03:50:20PM -0300, Jo??o Paulo Zavanela wrote:
> >> How many fields is recomended to create a primary key?
> >> I'm thinking to create one with 6 fields, is much?
> >
> > Normally a primary key would just be a single column. When you start
> > going to that many I'd probably have a serial column as the primary key,
> > and a UNIQUE index on those six fields. Depends on what you're doing,
> > though unless you've got a few years experience I'd be tempted to stay
> > away from primary keys of more than a single column.
>
> Fie on you evil synthetic key lovers. Long live the Natural Key!

Really? I started off with everything using sequences and everything
was good. Then I found I wanted to do more complicated things so I
started to transition to natural keys and things were better. Then
I took things too far and wanted something artificial back in my
life. I'm back to almost never using natural keys now, mainly because
interfacing with the outside world gets too complicated. When I'm just
doing stuff inside the database then I can use natural keys and all is
good, otherwise things just get too complicated.

I'll probably look back in another few years and remember how young and
naive I was back now.

Sam

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2007-11-16 20:06:46 Re: Primary Key
Previous Message Peter Eisentraut 2007-11-16 19:54:13 Call for translations