X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 903EA52B0E for ; Wed, 27 Jul 2005 17:08:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63271-03 for ; Wed, 27 Jul 2005 20:08:38 +0000 (GMT) Received: from qtm.net (mummra.qtm.net [216.163.32.14]) by svr1.postgresql.org (Postfix) with SMTP id CBBEA52ADD for ; Wed, 27 Jul 2005 17:08:36 -0300 (ADT) Received: (qmail 90421 invoked from network); 27 Jul 2005 20:08:36 -0000 Received: from unknown (HELO ?192.168.0.110?) (mur@216.163.42.222) by mummra.qtm.net with SMTP; 27 Jul 2005 20:08:36 -0000 Message-ID: <42E7E9B3.4080500@endpoint.com> Date: Wed, 27 Jul 2005 16:08:19 -0400 From: Jeff Boes Organization: End Point User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Foreign key with check? X-Enigmail-Version: 0.92.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200507/235 X-Sequence-Number: 22213 Given a table like this: create table primary ( a integer primary key, b boolean ); And another like this: create table secondary ( a integer, some_other_fields ); I would like a foreign key constraint on the "secondary" table that looks something like: foreign key (a, true) references primary (a, b) That is, a row in "secondary" is allowed to reference a row in "primary" if and only if that referenced row has (b = true). I think I have to do this with an additional trigger. Any other options?