Re: Sub-Entities

From: William D. Bartholomew <wbarthol_at_gmail.com>
Date: 3 Jul 2005 00:21:58 -0700
Message-ID: <1120375318.556261.228230_at_g49g2000cwa.googlegroups.com>


> Now start hiding all this stuff in VIEWs immediately and add an INSTEAD
> OF trigger to those VIEWs. This is an awful design and total kludge
> that tells the world you are an OO programmer who does not understand
> RM.

Does your "awful design" comment relate to hiding all of the stuff in VIEWs or to the table design as a whole? If to the table design is there an alternative? If so, what is it? These entities are different (shown by the fact they have different attributes) which means they should be stored in different tables, but the entities can be used interchangably in some places. For example:

CREATE TABLE dbo.Orders
(
OrderNumber int NOT NULL PRIMARY KEY,
ClientIdentifier varchar(20) NOT NULL REFERENCES dbo.Clients( ClientIdentifier ),
...
)

Orders can made by 1 individual OR 1 organization. If individuals and organizations don't share a parent table what should the DDL for the orders table be?

CREATE TABLE dbo.Orders
(
OrderNumber int NOT NULL PRIMARY KEY,
CompanyIdentifier varchar(20) NULL REFERENCES dbo.Companies( ClientIdentifier ),
IndividualIdentifier varchar(20) NULL REFERENCES dbo.Individuals( ClientIdentifier ),
...
)

With a CHECK constaint to ensure you only fill in one or the other? Received on Sun Jul 03 2005 - 09:21:58 CEST

Original text of this message