I was studying the EER model, when I had this doubt. Could you let me know why we have a UNION type to describe a union of 3 superclasses. Couldnt we just have a multiple inheritance model?
Or is there some other difference between the two?
Union of person,bank,company into owner relation Multiple inheritance of the same relations
The Owner example you give is used frequently in the EER literature to explain union(or category). I don't find this example particularly illuminating, as it could easily be expressed by inheritance as well.
The difference between union and inheritance is that each child entity C that inherits from a parent entity P inherits all properties (attributes, relationships) from P, whereas no such inheritance mechanism takes place for a union. The union just comprises a subset of its member entities.
Now, the child entities in your owner example all contain a name and address and could therefore be expressed by inheritance. In fact, the parent entity should be called Person (natural or legal), which would make clear that each person has certain attributes and could also act as an owner.
A better example might be an archive. It can contain lots of things that don't need to have anything in common, apart from trivialities like being an object. So you might have entities Letter, Bill, and ProductDescription, which have no common properties, but can all act as ArchiveContent.
So the recommendation is: If the entities have some semantic relationship that is expressed by common properties, use inheritance. If they are just thrown together for a specific purpose, use union.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With