I read Doctrine 2 Inheritance Mapping with Association , but I’ll say that if you needed Animal
for an independent entity, say, to create option lists.
In this case, the discriminator column for Pet
is in the view column in the animal table
.
So the classes will be something like this.
class Animal { $id; $species; } abstract class Pet { $id $species; } class Dog extends Pet { } class Cat extends Pet { } class Owner { $pets }
I see a couple of problems.
The Animal
table does not have a foreign key for owner
. Thus, $pets
will not work.
Animal
and Pet
more or less the same. If someone changes something in Animal
, these changes will not be reflected in any subclasses of Pet
.
A possible solution to the first problem would be to have an additional table named Pet
, but there is still an association problem, since the discriminator column is still in the Animal
table and duplicating the column in Pet
will break normalization.
source share