cancel
Showing results for 
Search instead for 
Did you mean: 

Using inheritance in a logical model to reuse lists of attributes

costa-b
Explorer
0 Kudos

Hello,

In the context of a logical model, I have two lists of attributes that I need to add to a few tables. As an example I have list of Person attributes (List1): First Name, Last Name, Middle Initial, Birth Date, Gender. I have a second list (List2) of other attributes, specific to some relationships such as Qualification Date, Marriage Date etc.


I would like to add List1 and List2 to a few entities, and in one case both List1 and List2 to a single entity, and ideally I would like to maintain just List1 & List2 manually, and whenever I modify these lists, the attributes are changed automatically in those tables I added the lists to.


What is the best way to achieve this in PD?


One way I found is to do it using multiple inheritance. I created two parent entities, let's call them ParentEntity1 with List1 attributes and ParentEntity2 with List2 attributes. Then Entity1 can inherit from ParentEntity1 and ParentEntity2. I turned the generation off for the parent entities and I get Entity1 with both lists of attributes.


Is this pattern something that it is frowned upon? ParentEntity1 and ParentEntity2 don't have primary keys, so Entity1 simply inherits the attributes from both parent entities and I added its primary key manually. Checking the model passes with warnings. Technically it is not a correct model because all entities should have primary keys but it allows me to maintain the lists of attributes in one place only.

Interestingly enough, ER Studio doesn't allow multiple inheritance.

Other ways to do this?

Let me know if you have any feedback.

Thanks

logicalmodel.txt - to open the model rename the file with the extension ldm.

PS. The upload doesn't work in FireFox but it works in Chrome.

Accepted Solutions (0)

Answers (1)

Answers (1)

GeorgeMcGeachie
Active Contributor
0 Kudos

This is a misuse of inheritance, and it'll come back to bite you at some point, so I hope you've taken precautions:

  • in the inheritance, generate the children, not the parent
  • in the parent entities, set 'Generate' to False (this will prevent them being generated in a PDM)

I'd find a different way of achieving your aim, if you can. Ideally, it would be great if PD allowed you to add a collection of attributes to an entity, but it doesn't. In the absence of that, you could use a model extension to define an extended collection on entities, linking to your parent 1 and parent 2 entities. This would tell you that Entity1 needs to have the attributes from both parent entities.

Also have a script (possibly linked to a custom check or transformation) that ensures that Entity1 contains a replica of all the attributes from the parent entities. Using replicas of attributes ensures that they're updated if you change the parent attribute.