query to create a subtype with no unique parameters

189 Views Asked by At

Lets say I have a Supertype entity called Box and three subtypes BlackBox, WhiteBox, GrayBox. Blackbox and WhiteBox have no parameters of their own. Box has BoxCode as primary key and BlackBox has a BLBoxCode as its pk in my relational diagram.

How do I create the table for BlackBox in MS SQL ? Please help.

Thanks.

1

There are 1 best solutions below

4
On

The same column should be both primary key and foreign key to the immediate supertype.

CREATE TABLE BlackBox
(
    box_id int NOT NULL PRIMARY KEY REFERENCES Box (box_id),
    ...
)