Entity Inheritance hierarchies are an essential tool for anyone working on Logical Data Models. In this post I’m going to show two ways in which the customisation features of PowerDesigner are useful when dealing with Inheritance Hierarchies.
1. With a complex inheritance hierarchy (I’ve seen them go 5 or 6 levels deep) it can sometimes be tricky to keep track of the entity that is the “Ultimate Parent”, the entity at the top of the inheritance tree.
2. In Conceptual and Logical Data Models, PowerDesigner allows an entity to be a child of more than one hierarchy. I’m not a database specialist so I take advice from other people, and I’ve been told that this multiple inheritance needs to be avoided when designing a relational database, so I may want to make it obvious to modellers when they create something we can’t implement.
For example, here’s an inheritance hierarchy for the Country entity.
It has three levels, and multiple inheritance – the entity Country with 1 Border has two parents, Landlocked Country and Whole-Island Country. My modelling standards don’t allow me to create multiple inheritance in the LDM, but the tool doesn’t stop me from doing so; I probably wouldn’t want to stop modellers from doing this, but I would like to flag it when it does happen, so we can fix the model for them.
I’ve built a model extension for the PowerDesigner LDM that provides information to the modeller about how an entity fits into inheritance hierarchies. Here’s an example for an entity that has a single parent:
The entity is at level three in the hierarchy, and the ultimate parent is the entity at the top of the tree (Country is at level 1). The form shows three new properties that have been added in the extension:
- The level within the inheritance hierarchy
- A Boolean property, set to TRUE if the entity has more than one parent
- The name of the ultimate parent entity
- The inheritance link that links the entity to its parent
The form also shows the list of parent entities, which is available as standard but not normally displayed on a form.
Here’s the same form for the entity that has more than one parent:
We cannot determine the Ultimate Parent, so that has been set to << Multiple >>.
It’s fine presenting this information to the modeller in this form, but what if the model is large and complicated, and you don’t want to rely on just your eyeballs to detect issues? The model extension also includes a couple of custom model checks for Entities; it reports an error if an entity has multiple parents, or if it has multiple child inheritances.
Here are the results for our simple model of countries:
The model extension required to provide these features is not large or complex and contains around 40 lines of VBScript (most of that is used to discover the Ultimate Parent entity).
Here’s an outline of the extension:
This shows the script used to set the level number – the value is set to “1” if the entity does not have a parent, or to the level number of the parent, plus 1.