Re: two primairy key in one table ?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Curt Sampson <cjs(at)cynic(dot)net>
Cc: Angela Luyf <a(dot)c(dot)luyf(at)amc(dot)uva(dot)nl>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: two primairy key in one table ?
Date: 2002-07-08 05:21:26
Message-ID: 20020707221726.A22659-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 8 Jul 2002, Curt Sampson wrote:

> On Fri, 5 Jul 2002, Stephan Szabo wrote:
>
> > On Thu, 4 Jul 2002, Angela Luyf wrote:
> >
> > > I have a database model where a many to many relation is used, so i need
> > > to create a table with two primary key.
> >
> > You can't have multiple primary keys in a table (per SQL spec) but are
> > you sure that's what you want as opposed to a single key made of two
> > columns?
>
> I certainly read this as "two primary keys" in the sense of "two
> candidate keys," and I was quite suprised that everybody else
> interpreted this as "one primary key consisting of data from two
> columns."
>
> However, I don't see any problem here at all. That's because,
> relationally speaking, I am of the opinion that the concept of a PRIMARY
> KEY is entirely useless. If you've got two candidate keys on a table,
> and unique constraints on both of them, there's nothing at all that
> makes one better than the other.

True, but, trying to use two separate candidate keys on each of the
linking columns alone won't really make a many to many relationship.
I'm assuming that the linkage is what is supposed to be unique here
not the individual parts.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2002-07-08 05:33:21 Re: I am being interviewed by OReilly
Previous Message Ron Snyder 2002-07-08 05:04:18 Re: I am being interviewed by OReilly