Je Mon, 25 Jun 2001 09:34:01 +0200 (CEST),
Andreas Tille <[EMAIL PROTECTED]> scribis:
> CREATE TABLE ResKulturDetail
> (
> IdLabNr int,
> IdIndex smallint
> );
>
> CREATE TABLE ResKulturDetailDay
> (
> IdLabNr int,
> IdIndex smallint
> );
>
> CREATE INDEX IX_IdLabNr_KulturDetail ON ResKulturDetail(IdLabNr) ;
>
> ALTER TABLE ResKulturDetailDay ADD CONSTRAINT FK_ResKulturDetailDay
> FOREIGN KEY (IdLabNr,IdIndex)
> REFERENCES ResKulturDetail (IdLabNr,IdIndex) ;
> Can anybody explain, why the foreign key constraint fails?
According to the documentation for CREATE TABLE:
In addition, the referenced columns are supposed to be the columns
of a UNIQUE constraint in the referenced table, however Postgres
does not enforce this.
Well, it looks like PostgreSQL *does* enforce it. Try it with:
CREATE UNIQUE INDEX IX_IdLabNr_KulturDetail
ON ResKulturDetail(IdLabNr, IdIndex) ;
I'm not sure why this restriction is necessary...
--
Itai Zukerman <http://www.math-hat.com/~zukerman/>
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]