Is it possible to add a logic Constraint to a Foreign Key?

后端 未结 7 1758
闹比i
闹比i 2021-01-05 15:29

I\'ve got two tables and I\'ve added a foreign key constraint. Kewl - works great. Now, is it possible to further constrain that relationship against some data in the parent

7条回答
  •  孤城傲影
    2021-01-05 15:51

    Have a unique constraint on Animals(AnimalId, AnimalType) Add AnimalType to Mammals, and use a check constraint to make sure it is always 1. Have a FK refer to (AnimalId, AnimalType).

提交回复
热议问题