Skip to Content
0

Using inheritance in a logical model to reuse lists of attributes

Jul 06 at 07:29 AM

19

avatar image

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.

erd.png (27.8 kB)
logicalmodel.txt (69.1 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

George McGeachie Jul 06 at 08:48 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded