Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 7E8949FB9C2 for ; Wed, 24 Oct 2007 00:01:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 87800-06 for ; Wed, 24 Oct 2007 00:01:24 -0300 (ADT) X-Greylist: whitelisted by SQLgrey-1.7.5 Received: from mail14.syd.optusnet.com.au (mail14.syd.optusnet.com.au [211.29.132.195]) by postgresql.org (Postfix) with ESMTP id B6B3F9FB9A4 for ; Wed, 24 Oct 2007 00:01:28 -0300 (ADT) Received: from [127.0.0.1] (online4-new.lnk.telstra.net [139.130.169.227]) (authenticated sender plengada@optusnet.com.au) by mail14.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id l9O31M2G005813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 24 Oct 2007 13:01:25 +1000 Message-ID: <471EB55F.5050600@autoledgers.com.au> Date: Wed, 24 Oct 2007 11:00:47 +0800 From: Paul Lambert User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Tom Lane CC: pgsql-sql Subject: Re: Quick question re foreign keys. References: <471EA7D5.9040403@autoledgers.com.au> <21715.1193193880@sss.pgh.pa.us> In-Reply-To: <21715.1193193880@sss.pgh.pa.us> 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/97 X-Sequence-Number: 29469 Tom Lane wrote: > > If I'm understanding you correctly, the problem is not the foreign key, > it's that you marked the column NOT NULL. A foreign key constraint by > itself will allow a NULL in the referencing column to pass. You choose > whether you want to allow that or not by separately applying a NOT NULL > constraint or not. > > regards, tom lane It's marked not null as a result of being part of the primary key for that table which I can't really get around. I can get away with not having the foreign key though, so I'll have to go down that path. Cheers, P. -- Paul Lambert Database Administrator AutoLedgers