foreign key check

From: David Gardner <david(at)gardnerit(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: foreign key check
Date: 2007-06-19 00:47:39
Message-ID: 467727AB.5020300@gardnerit.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David Gardner 2007-06-19 00:52:58 Re: foreign key check
Previous Message Rodrigo De León 2007-06-18 21:17:59 Re: Postgres VS Oracle