Re: Am I supposed to be all scared of compound primary keys?

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Mike Christensen <mike(at)kitchenpc(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Am I supposed to be all scared of compound primary keys?
Date: 2010-05-02 02:35:46
Message-ID: EE3CEC87-A600-4532-83A2-FA5A5C3F302C@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On May 1, 2010, at 7:25 PM, Mike Christensen wrote:

> \And I quote:
>
> Quick Note: Composite keys are highly discouraged. Use only when you
> have no other alternative.
>
> I get the feeling they're discouraged from a SQL point of view, but
> it doesn't actually say why anywhere. Is there any good reason to
> avoid using composite keys on a table? Why waste the space of an
> extra key if you don't have to? Thanks!

A composite key is generally better than creating a surrogate key just
so you have a single-column key. It's possible that the note is
referring to systems that handle composite keys poorly (PostgreSQL
handles them just fine), or are concerned about ORMs which don't
support them at all (like Django's) or support them badly.

--
-- Christophe Pettus
xof(at)thebuild(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message justin@magwerks.com 2010-05-02 03:08:02 Re: Am I supposed to be all scared of compound primary keys?
Previous Message Scott Marlowe 2010-05-02 02:32:12 Re: Am I supposed to be all scared of compound primary keys?