Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f78GTQ697897 for ; Wed, 8 Aug 2001 12:29:26 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 98845; Wed, 08 Aug 2001 09:29:17 -0700 From: "Josh Berkus" Subject: Re: REFERENCES constraint To: Cedar Cox , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Wed, 08 Aug 2001 09:29:17 -0700 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200108/127 X-Sequence-Number: 4348 Cedar, > 1. Can a column reference more than one table? (This assumes you use > a > single sequence to generate the IDs for both "tbla" and "tblb". I > guess > you would also have the problem of enforcing a unique index. Say > what?! > A unique index across multiple tables.. absurd :) eg.. > > CREATE TABLE blah ( > id int4, > f_id int4 REFERENCES tbla (id) REFERENCES tblb (id) > ) I'd reccomend, instead, having blah reference tbla and tbla reference tblb. It'd have the same effect, without forcing you to monkey around with custom triggers. > 2. Can a column reference another column in the same table? eg.. > > CREATE TABLE bloo ( > id int4, > p_id int4 REFERENCES bloo (id) > -- or > --p_id int4 REFERENCES (id) > ) Er ... why would you want to? -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco