From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | Markus Bertheau <twanger(at)bluetwanger(dot)de>, olly(at)lfix(dot)co(dot)uk |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: multi column foreign key for implicitly unique columns |
Date: | 2004-08-18 02:45:15 |
Message-ID: | 200408171945.15663.josh@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Markus,
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);
This will add the unique constraint that Postgres wants without changing your
data at all.
--
Josh Berkus
Aglio Database Solutions
San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2004-08-18 02:55:11 | SQL Challenge: Arbitrary Cross-tab |
Previous Message | Bruno Wolff III | 2004-08-17 17:31:50 | Re: SELECT MAX(c) FROM (SELECT ... FOR UPDATE) AS foo |