From: Josh Berkus <josh@agliodbs.com>
To: pierre@kahuna.versions.com
To: pgsql-sql@postgresql.org
Subject: Re: Table design issue....
Date: Mon, 11 Jun 2001 10:44:01 -0700
Message-ID: <web-70284@davinci.ethosmedia.com> (raw)
In-Reply-To: <20010611143846.31514.qmail@kahuna.versions.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com, pierre@kahuna.versions.com
Subject: Re: Table design issue....
In-Reply-To: <web-70284@davinci.ethosmedia.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox