From: Bruno Wolff III <bruno@wolff.to>
To: Epps, Aaron M. <Epps.Aaron@mayo.edu>
Cc: 'pgsql-admin@postgresql.org' <pgsql-admin@postgresql.org>
Subject: Re: Column References
Date: Sat, 1 Nov 2003 11:20:58 -0600
Message-ID: <20031101172058.GA20268@wolff.to> (raw)
In-Reply-To: <AFB1612D9C37D21182E0006008A1F6F813D30E8C@excsrv14.mayo.edu>
References: <AFB1612D9C37D21182E0006008A1F6F813D30E8C@excsrv14.mayo.edu>
On Fri, Oct 31, 2003 at 13:44:40 -0600,
"Epps, Aaron M." <Epps.Aaron@mayo.edu> wrote:
> I've got a question about references, is it possible to specify criteria for the Reference. For example, Table 1 has Field1 That References Field1 in Table2, However I only want Field 1 in Table 1 to reference the Records in Table2 that have the Valid Field set to TRUE. In other words, I don't want the user to be able to enter invalid records from table 2 into field 1 in table 1. Is there a different way of accomplishing the same thing?
The way I have done this is to use redundant data in table1. For example in
your case you might include a Valid field in table 1 with a constraint
forcing it to always be true. Then you can use a two column foreign key
reference from table 1 to table 2 that will enforce your constraint.
(You will also need to make a unique index on the two column combination
in table2.)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: bruno@wolff.to, Epps.Aaron@mayo.edu
Subject: Re: Column References
In-Reply-To: <20031101172058.GA20268@wolff.to>
References: <AFB1612D9C37D21182E0006008A1F6F813D30E8C@excsrv14.mayo.edu> <20031101172058.GA20268@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox