Re: Category Types

From: --CELKO-- <71062.1056_at_compuserve.com>
Date: 17 Jun 2003 15:07:35 -0700
Message-ID: <c0d87ec0.0306171407.631e8994_at_posting.google.com>


>> Are category types a bad database design methodology? <<

Yes. Many years ago, the INCITS H2 Database Standards Committee(nee ANSI X3H2 Database Standards Committee) had a meeting in Rapid City, South Dakota. We had Mount Rushmore and Bjarne Stroustrup as special attractions. Mr. Stroustrup did his slide show about Bell Labs inventing C++ and OO programming for us and we got to ask questions.

One of the questions was how we should put OO stuff into SQL. His answer was that Bells Labs, with all their talent, had tried four different approaches to this problem and come the conclusion that you should not do it. OO was great for programming but deadly for data.

I have watched people try to force OO models into SQL and it falls apart in about a year. Every typo becomes a new attribute or class, queries that would have been so easy in a relational model are now mutli-table monster outer joins, redundancy grows at an exponential rates, constraints are vitually impossible to write so you can kiss data integrity goodbye, etc.

Ownership in your example is a relationship and not an attribute, but you have no table for it; you thought that the fake class hierarchy would be enough.

CREATE TABLE AutoTitles
(vin CHAR(17) NOT NULL

     REFERENCES Vehicles(vin)
     ON DELETE CASCADE
     ON UPDATE CASCADE,
 owner_id INTEGER NOT NULL
     REFERENCES Owners(owner_id)
     ON DELETE CASCADE
     ON UPDATE CASCADE,

 ...
 PRIMARY KEY (vin, owner_id));

CREATE TABLE Vehicles
(vin CHAR(17) NOT NULL PRIMARY KEY,
 ...);

CREATE TABLE Owners
(owner_id INTEGER NOT NULL PRIMARY KEY,
 legal_status CHAR(1) DEFAULT 'p' NOT NULL

        CHECK (legal_status IN ('p, 'b', 'c'),  owner_name ...
); Received on Wed Jun 18 2003 - 00:07:35 CEST

Original text of this message