You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Within the UmpleOnline, the users can generate the relational database tables based on the modeling language. In a sample scenario, a user can create a model, and generate the SQL to create the associated database, tables, columns.
The system does not generate relational columns between the tables that are in the "isA" relationship (generalization).
For example (in 2D shapes): Circle isA EllipticalShape, and EllipticalShape isA Shape2D. Therefore, there is a relation between Circle >> EllipticalShape >> Shape2D. So, in a relational database system, the primary key of Shape2D table should exist inside the EllipticalShape table as a foreign key. A similar case will happen for Circle and EllipticalShape. the primary key of EllipticalShape table should exist inside the Circle table as a foreign key.
Steps to Reproduce
Click the "Tools" menu item, select the example as "Class Diagrams >> "2DShapes".
Under the "Generate" section, select the target programming language as "Sql". Click "Generate It".
Scroll a bit down and check the statement of creating the "Circle" table.
There is no column defined within the "Circle" table to convert the isA relation between the "Circle" and "EllipticalShape" table.
For an isA association, the second table (Circle) should have a foreign key column taken from the first table (EllipticalShape).
The text was updated successfully, but these errors were encountered:
it is certainly an issue that there should be proper generation for generalizations. The person who raised this issue mistakenly treated them as associations, but they are certainly not associations.
So the way to solve this is not necessarily as described in this issue. There are two ways of doing ORM (object-relational mapping) for generalizations. Let's imagine an object of a class at the bottom of the hierarchy
Create an object for each class, from the bottom of the hierarchy to the top, and link them with a common key.
Create just an object at the bottom of the hierarchy that has all the fields from that class and its parent classes.
Which of these is the correct solution is not always apparent. Option 1 may well be the best solution. But both solutions can be highly inefficient in some situations (one of the reasons why relational databases themselves are often the wrong way to design a system)
I am marking this as needing more analysis.
One solution would be to enable the SQL generator to choose either option, using suboptions. In UmpleOnline, that might require having two generator labels.
This problem needs solving, but with team discussion.
Update: I think that to make code involving associations more complete, we should follow option 1 above. If an instance of a subclass is created, then there would be tables in two rows; one row for the object in the superclass and one row in the subclass. They would both need to have the same key columns. If there is key already specified in Umple, these would be used, otherwise we would need to generate an integer key.