X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id B0B3D30F680 for ; Mon, 23 Jun 2003 17:20:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 17427-07 for ; Mon, 23 Jun 2003 14:20:04 -0300 (ADT) Received: from www.postgresql.com (www.postgresql.com [64.117.225.209]) by svr1.postgresql.org (Postfix) with ESMTP id D039230F6F0 for ; Mon, 23 Jun 2003 14:19:12 -0300 (ADT) Received: from fluor.cenes.de (pD9E7747C.dip.t-dialin.net [217.231.116.124]) by www.postgresql.com (Postfix) with ESMTP id C11D5CF6518 for ; Mon, 23 Jun 2003 11:01:43 -0300 (ADT) Received: by fluor.cenes.de (Postfix, from userid 1000) id A5C6766725; Mon, 23 Jun 2003 15:58:21 +0200 (CEST) Subject: multi-table unique index From: Markus Bertheau To: PGSQL-SQL Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1056376700.2037.2.camel@fluor> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.0 Date: 23 Jun 2003 15:58:20 +0200 X-Archive-Number: 200306/268 X-Sequence-Number: 14026 -- Suppose I have several types of foos create table foo_types ( foo_type_id serial primary key, foo_name text not null ); -- And the foos itself: create table foo ( foo_id serial primary key, foo_type_id int not null references foo_types, foo_general_data1 text ); -- 1st special foo: create table foo_1 ( foo_1_id serial primary key, foo_id int not null references foo, foo_1_data1 int, foo_1_data2 text ); -- 2nd special foo: create table foo_2 ( foo_2_id serial primary key, foo_id int not null references foo, foo_2_data1 numeric(8,2), foo_2_data2 timestamp ); -- And I have bars that each have zero or more (special) foos. create table bar ( bar_id serial primary key ); create table bar_foos ( bar_id int not null references bar, foo_id int not null references foo ); -- Now how do I prevent that I can insert a foo_1 and a foo_2 with -- the same foo_id? Or is the design errorneous itself? -- Markus Bertheau Berlin, Berlin, Germany