Is foreign key reference from two different primary key from two different tables valid?
- by arundex
I have a foreign key that has to refer primary keys of two different tables.
Table 1: animal
animal_ id (primary key)
Table 2: bird
bird_ id (primary key)
Table 3: Pet_info
pet_id,
type ENUM ('bird', 'animal')
foreign key (pet_ id) references animal(animal_id), bird(bird_id)
So, I need to check for pet_id either from animal or bird table depending on the need. Is this valid? Or should I go for some restructuring . . .
NOTE: I referred this . . but I'm not sure whether I have to change my existing design