Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 1E0F19FB778 for ; Tue, 23 Oct 2007 23:03:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 36002-02 for ; Tue, 23 Oct 2007 23:03:36 -0300 (ADT) X-Greylist: whitelisted by SQLgrey-1.7.5 Received: from mail05.syd.optusnet.com.au (mail05.syd.optusnet.com.au [211.29.132.186]) by postgresql.org (Postfix) with ESMTP id 0D45A9F992C for ; Tue, 23 Oct 2007 23:03:41 -0300 (ADT) Received: from [127.0.0.1] (online4-new.lnk.telstra.net [139.130.169.227]) (authenticated sender plengada@optusnet.com.au) by mail05.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id l9O23avb029218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 24 Oct 2007 12:03:38 +1000 Message-ID: <471EA7D5.9040403@autoledgers.com.au> Date: Wed, 24 Oct 2007 10:03:01 +0800 From: Paul Lambert User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: pgsql-sql Subject: Quick question re foreign keys. Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/93 X-Sequence-Number: 29465 I have a table where one column references by foreign key a column from another table. However, the column in this first table does not always contain data which results in a not-null constraint violation when I attempt an insert. My question therefore is, is it possible to create a foreign key that is conditional, i.e. only enforce the foreign key where the value in that table is not null. -- Paul Lambert Database Administrator AutoLedgers