Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A9F03476898 for ; Fri, 29 Nov 2002 22:52:10 -0500 (EST) Received: from smtp7.andrew.cmu.edu (SMTP7.andrew.cmu.edu [128.2.10.87]) by postgresql.org (Postfix) with ESMTP id 7900B476937 for ; Fri, 29 Nov 2002 22:51:51 -0500 (EST) Received: from cmu.edu (MCUBE.RES.cmu.edu [128.2.161.131]) (user=amcauley mech=PLAIN (0 bits)) by smtp7.andrew.cmu.edu (8.12.3.Beta2/8.12.3.Beta2) with ESMTP id gAU3ppBI003456 (version=TLSv1/SSLv3 cipher=DES-CBC3-SHA bits=168 verify=NOT) for ; Fri, 29 Nov 2002 22:51:51 -0500 Date: Fri, 29 Nov 2002 22:50:27 -0500 Mime-Version: 1.0 (Apple Message framework v548) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: From: "A.M." To: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: X-Mailer: Apple Mail (2.548) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/442 X-Sequence-Number: 10584 I have a reference which is guaranteed not to have a valid reference (preferably NULL) until it is processed later. How can I defer a reference entry so that both NULL and an actual reference are valid in the reference field? The processing which I speak of takes place later and not in the same transaction (thus making DEFERRABLE useless, right?). A solution I thought of is to forget keys and just make it an INT8 since I am also guaranteed that its referenced item is never deleted. But certainly, there is a more reliable way to do it, right? In summary, what I want is field INT8 REFERENCES sometable NULL OK or field INT8 CHECK(SELECT id FROM someothertable WHERE field=id) (can I do this? this allows NULL right?) The rule is ref2 can either be a valid reference or NULL. CREATE TABLE thetable( ref2 INT8 REFERENCES someothertable, ... ); Thanks for any help. ><><><><><><><><>< AgentM agentm@cmu.edu