From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | David Gardner <david(at)gardnerit(dot)net> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: foreign key check |
Date: | 2007-06-19 01:39:08 |
Message-ID: | 13158.1182217148@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
David Gardner <david(at)gardnerit(dot)net> writes:
> 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?
Nothing that would be reliable in the face of concurrent changes to
the third table --- unless you're willing to take out exclusive locks,
which will create performance issues as well as (probably) deadlock
problems.
I suggest thinking about how to refactor your schema to avoid this
situation.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2007-06-19 02:01:50 | Re: foreign key check |
Previous Message | David Gardner | 2007-06-19 00:52:58 | Re: foreign key check |