Skip site navigation (1) Skip section navigation (2)

Re: multi column foreign key for implicitly unique columns

From: Markus Bertheau <twanger(at)bluetwanger(dot)de>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: olly(at)lfix(dot)co(dot)uk, pgsql-sql(at)postgresql(dot)org
Subject: Re: multi column foreign key for implicitly unique columns
Date: 2004-08-18 06:00:21
Message-ID: 1092808820.2728.27.camel@teetnang (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
В Срд, 18.08.2004, в 04:45, Josh Berkus пишет:
> Markus,

Hi Josh,

> Hey, I see you figured out a workaround to writing a trigger for this.  Let's 
> see if we can make it work.
> ERROR:  there is no unique constraint matching given keys
>         for referenced table "objects"
> The reason for this is that CASCADE behavior gets quite odd when there is an 
> FK reference to a non-unique column.   We used to allow it, in 7.1, and I was 
> responsible for a number of bug reports that led to us disallowing it.   It 
> should be theoretically implementable and relationally sound but will require 
> a *lot* of troubleshooting to make work.   So far, nobody's really interested 
> enough.
> However, you have an easy way out:
> ALTER TABLE objects ADD CONSTRAINT obj_unq_2 UNIQUE (name, class_name);

I was worried about the performance hit because (name, class_name) will
always be unique, yet they will be checked for uniqueness.


Markus Bertheau <twanger(at)bluetwanger(dot)de>

In response to

pgsql-sql by date

Next:From: Theo GalanakisDate: 2004-08-18 06:11:55
Previous:From: Joe ConwayDate: 2004-08-18 05:15:59
Subject: Re: SQL Challenge: Arbitrary Cross-tab

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group