Re: SQL for Modeling Generalization Hierarchies

From: Erland Sommarskog <sommar_at_algonet.se>
Date: Sat, 29 May 2004 22:05:37 +0000 (UTC)
Message-ID: <Xns94F9AEBC8C6Yazorman_at_127.0.0.1>


--CELKO-- (jcelko212_at_earthlink.net) writes:
> CREATE TABLE Vehicles
> (vin CHAR(17) NOT NULL PRIMARY KEY,
> vehicle_type CHAR(3) NOT NULL
> CHECK(vehicle_type IN ('SUV', 'SED')),
> UNIQUE (vin, vehicle_type),
> ..);
>
> Notice the overlapping candidate keys. I then use a compound candidate
> key (vin, vehicle_type) and a constraint in each sub-class table to
> assure that the vehicle_type is locked and agrees with the Vehicles
> table. Add some DRI actions and you are done:

Ah! Interesting trick! I'll save a mental note about that.

-- 
Erland Sommarskog, SQL Server MVP, sommar_at_algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Received on Sun May 30 2004 - 00:05:37 CEST

Original text of this message