Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5BHi3E09370 for ; Mon, 11 Jun 2001 13:44:03 -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 70284; Mon, 11 Jun 2001 10:44:01 -0700 From: "Josh Berkus" Subject: Re: Table design issue.... To: pierre@kahuna.versions.com, pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Mon, 11 Jun 2001 10:44:01 -0700 Message-ID: In-Reply-To: <20010611143846.31514.qmail@kahuna.versions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200106/164 X-Sequence-Number: 3385 Pierre, > Ideas? Comments? Suggestions? Am I being crazy? Yes. To be blunt, you've picked one of the worst possible database designs for any useful purpose. This is, however, a common mistake as far too many books and training courses teach how to write SQL without teaching how to design a database. What you really want is something like this: CREATE TABLE tables ( tableid CHAR(1) NOT NULL PRIMARY KEY ); CREATE TABLE attributes ( tableid CHAR(1) NOT NULL REFERENCES tables(tableid), attributeid CHAR(1) NOT NULL, CONSTRAINT tab_attr_PK PRIMARY KEY (tableid, attributeid) ); This makes your select statement possible: SELECT tableid FROM attributes WHERE attributeid = 'C' GROUP BY tableid ORDER BY tableid; If your application requirements are more complicated than this, you need to either: a) hire a relational design expert, or b) become one. Books I'd recommend for the latter are Database Design for Mere Mortals and Practical Issues in Database Design (F. Pascal). -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