Implement isA relationship in SQL SERVER, cannot insert in anyside

278 views Asked by At

I have table structure (pseudo):

Order(
    order_id int PK identity(1,1),
    order_date datetime
)

GiftOrder(
    order_id int Primary KEY FK Order(order_id),
    ReceiverAddress nvarchar(200),
    Wrapped bit
)

GiftOrder isA Order, but when I make the foreign key from GiftOrder to Order, its make a two-way arrow relationship (I think strongly 1-1), and I can't insert record in Order or OrderRecord at all

1

There are 1 answers

0
Rahul On

You can change your GiftOrder table structure to be like below having only the required field with ISA relationship entity.

Order(
    order_id int PK identity(1,1),
    order_date datetime,
    ReceiverAddress nvarchar(200),
)

GiftOrder(
    id int Primary KEY,        
    Wrapped bit,
    order_id int FK Order(order_id)
)