Re: multi column foreign key for implicitly unique columns

From: Richard Huxton <dev(at)archonet(dot)com>
To: Markus Bertheau <twanger(at)bluetwanger(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: multi column foreign key for implicitly unique columns
Date: 2004-08-17 09:52:29
Message-ID: 4121D55D.1040105@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Markus Bertheau wrote:
> Hi,
>
> PostgreSQL doesn't allow the creation of a foreign key to a combination
> of fields that has got no dedicated unique key but is unique nonetheless
> because a subset of the combination of fields has a unique constraint.
[snip example]
> Is this on purpose? I think the foreign key should be allowed. Creating
> an extra unique key only has a negative impact on performance, right?

As you say, the uniqueness is guaranteed so there's no good reason why
it couldn't be made to work. It's probably more of an implementation
issue. Unique constraints are implemented with an index, so I'm guessing
the FK code assumes there is an index there to check against.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dino Vliet 2004-08-17 10:44:37 only last records in subgroups
Previous Message Markus Bertheau 2004-08-17 09:49:57 Re: multi column foreign key for implicitly unique columns