X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3D984D1B503 for ; Sat, 1 Nov 2003 17:23:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62889-03 for ; Sat, 1 Nov 2003 13:22:54 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id A3588D1B57F for ; Sat, 1 Nov 2003 13:22:53 -0400 (AST) Received: (qmail 20966 invoked by uid 500); 1 Nov 2003 17:20:58 -0000 Date: Sat, 1 Nov 2003 11:20:58 -0600 From: Bruno Wolff III To: "Epps, Aaron M." Cc: "'pgsql-admin@postgresql.org'" Subject: Re: Column References Message-ID: <20031101172058.GA20268@wolff.to> Mail-Followup-To: "Epps, Aaron M." , "'pgsql-admin@postgresql.org'" References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/2 X-Sequence-Number: 10990 On Fri, Oct 31, 2003 at 13:44:40 -0600, "Epps, Aaron M." 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.)