Author Topic: Data Modelling - how to flatten class inheritance?  (Read 1708 times)

ds

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Data Modelling - how to flatten class inheritance?
« on: February 05, 2019, 04:59:48 pm »
Hi,

I've got a logical data model as a basic class diagram.  Some classes show generalisation to/inheritance from an industry model.  How to transform this into a database physical model where the inherited attributes are migrated to the "child" tables?  Posts such as this suggest flattening the generalisation first.  How is  this done?

Questions such as this point out that in a OO space it is correct that attributes aren't flattened.  However the target DBs are ER DBs which do not support inheritance.

Thanks,
Dylan

qwerty

  • EA Guru
  • *****
  • Posts: 10460
  • Karma: +230/-187
  • I'm no guru at all
    • View Profile
Re: Data Modelling - how to flatten class inheritance?
« Reply #1 on: February 05, 2019, 07:34:39 pm »
You could use a transformation script provided with EA.

However, I don't use that any more. The transformation leaves some ghost traces you can't access. The transformation process is something you usually do once and therefore want to to think over what you are doing. I just use the copy/paste to create a copy and create the DB model manually from the copy.

q.

Richard Freggi

  • EA User
  • **
  • Posts: 156
  • Karma: +7/-4
    • View Profile
Re: Data Modelling - how to flatten class inheritance?
« Reply #2 on: February 06, 2019, 12:33:00 am »
Hello DS I think the most common way is to do it yourself by hand.

It makes sense for this not to be automated because you as data modeler have different choices on how to translate generalization/specification (at logical level) into physical tables.

You can google this but basically you could merge the child classes with parent into one big table; or replicate the parent attributes/relationships to each of the children (along with any other database objects: indexes, triggers etc.); or set up a parent class with identifying relationship to its children.  Etc.  You have to pick the right solution based on your physical data model design criteria.  Good luck!

ds

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Data Modelling - how to flatten class inheritance?
« Reply #3 on: February 06, 2019, 03:52:19 pm »
Hello DS I think the most common way is to do it yourself by hand.

Hello Richard,

I'm not sure you mean "by hand".  Do you expose the inherited attributes, transcribe all the details from the keyboard/mouse and then delete the generalisation link?

Quote
It makes sense for this not to be automated because you as data modeler have different choices on how to translate generalization/specification (at logical level) into physical tables.

Maybe, but tools such as PowerDesigner allow you to specify this on each table to make the process repeatable.  Basically saves the "simultaneous update problem", where changes in one model aren't reflected properly in the other, etc.  But that isn't what I have in front of me.

Maybe the context is making this complicated.  I'd like to know is "What is the best way in EA to migrate attributes down from a generalisation/inheritance parent class to a child class?"  Retyping everything is practical, if typos are avoided.

Thanks,
Dylan

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2633
  • Karma: +41/-2
    • View Profile
Re: Data Modelling - how to flatten class inheritance?
« Reply #4 on: February 06, 2019, 04:15:58 pm »
"What is the best way in EA to migrate attributes down from a generalisation/inheritance parent class to a child class?"


To copy an attribute from one element to another, drag the attribute with the mouse from the Project Browser and drop it onto an element in the diagram.

To move an attribute from one element to another, drag the attribute with the mouse from the Project Browser and drop it onto an element in the Project Browser.
The Sparx Team
support@sparxsystems.com

Richard Freggi

  • EA User
  • **
  • Posts: 156
  • Karma: +7/-4
    • View Profile
Re: Data Modelling - how to flatten class inheritance?
« Reply #5 on: February 06, 2019, 04:17:01 pm »
Hi, I mean you have to manually edit the model by adding / deleting tables, columns and keys.

Yes I remember also ERWin had something like this but keep in mind that EA is much cheaper and just an excellent UML tool with a nice extension to support data modeling.  It is not a fully fledged data modeling tool nor it aspires / claims to be.

MaXyM

  • EA User
  • **
  • Posts: 120
  • Karma: +7/-0
    • View Profile
Re: Data Modelling - how to flatten class inheritance?
« Reply #6 on: May 10, 2019, 07:19:51 am »
Or use database which support tables inheritance. For example postgresql ;)