Re: Category Types
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.
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
CREATE TABLE Vehicles
CREATE TABLE Owners
(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));
(vin CHAR(17) NOT NULL PRIMARY KEY,
...);
(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
