Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL table does not create relational column for generalization in UmpleOnline #1728

Closed
shoevancar opened this issue May 28, 2021 · 3 comments
Assignees
Labels
Component-SemanticsAndGen Related to code generators in general and the meaning of Umple models Component-UmpleOnline Related to the UmpleOnline website Diffic-Med A non-trivial problem that may take over a week or may not be obvious how to fix or require analysis Priority-High This problem or enhancement is likely to be highly visible and or impactful of users Priority-NeedsMoreAnalysis The priority is uncertain until more analysis is done sql Issues to do with SQL generation

Comments

@shoevancar
Copy link
Contributor

shoevancar commented May 28, 2021

Summary

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

  1. Click the "Tools" menu item, select the example as "Class Diagrams >> "2DShapes".
    image
  2. Under the "Generate" section, select the target programming language as "Sql". Click "Generate It".
    image
  3. Scroll a bit down and check the statement of creating the "Circle" table.
    image

There is no column defined within the "Circle" table to convert the isA relation between the "Circle" and "EllipticalShape" table.

Expected Feature

For an isA association, the second table (Circle) should have a foreign key column taken from the first table (EllipticalShape).
image

@TimLethbridge TimLethbridge changed the title SQL table does not create relational column for isA association in UmpleOnline SQL table does not create relational column for generalization in UmpleOnline May 28, 2021
@TimLethbridge
Copy link
Member

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

  1. Create an object for each class, from the bottom of the hierarchy to the top, and link them with a common key.
  2. 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.

@TimLethbridge TimLethbridge added Component-SemanticsAndGen Related to code generators in general and the meaning of Umple models Component-UmpleOnline Related to the UmpleOnline website Diffic-Med A non-trivial problem that may take over a week or may not be obvious how to fix or require analysis Priority-NeedsMoreAnalysis The priority is uncertain until more analysis is done Priority-High This problem or enhancement is likely to be highly visible and or impactful of users labels May 28, 2021
@TimLethbridge
Copy link
Member

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.

@TimLethbridge
Copy link
Member

Fixed by #1800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component-SemanticsAndGen Related to code generators in general and the meaning of Umple models Component-UmpleOnline Related to the UmpleOnline website Diffic-Med A non-trivial problem that may take over a week or may not be obvious how to fix or require analysis Priority-High This problem or enhancement is likely to be highly visible and or impactful of users Priority-NeedsMoreAnalysis The priority is uncertain until more analysis is done sql Issues to do with SQL generation
Projects
None yet
Development

No branches or pull requests

3 participants