Re: foreign key check - Mailing list pgsql-novice

From David Gardner
Subject Re: foreign key check
Date
Msg-id 467728EA.1060406@gardnerit.net
Whole thread Raw
Responses Re: foreign key check  (Michael Glaesemann <grzm@seespotcode.net>)
List pgsql-novice
Woops I missed an important bit there. the select statement should look
like:
SELECT t1.idTwo JOIN t3 ON t3.id = t1.id WHERE t3.val=${variable}

David Gardner wrote:
> I have two tables t1, and t2 where t2.fid is a foreign key reference
> to t1.id. Except in this case only a subset of the values in t1 are
> valid, the values in t1 that are valid can be found by doing a:
> SELECT t1.id JOIN t3 ON t3.id = t1.id
> Is there some way to add this in as a check constraint? I could just
> write a pl/pgsql function to perform a check before inserting, but I
> am beginning to suspect that the reason I am running into this is
> because my schema isn't accurately representing the business logic of
> the application.
>


pgsql-novice by date:

Previous
From: Howard Eglowstein
Date:
Subject: Re: Stuck (again) trying to move a 7.x app and database to 8.2
Next
From: David Gardner
Date:
Subject: foreign key check