Forum

Two relations from one table to same table  Bottom

neple / Apr 24, 2008 / 01:06 Link to this post


Hello, firstly: thanks for great work on Modulestudio. I have been working on MDD for years now (Model to text transformations), and lately with GMF and the idea to use this to create a visual way of creating PN modules is brilliant!!!

So; I am trying to create a Module to be used for a site of the local hockey-team, and I have stumbled upon some strange issues. First, I have defined the table Game and the table Team. A game is typically played between two teams, so I created two relationships pointing from Team to Game (bwt quite the opposite of what I am used to from UML), and named them "homeTeam" and "awayTeam" respectively. When I generate the module and open the editor it shows two columns named Team. So I enter valid ids for teams in each of them (different numbers in the two cells), but when I store the value for the first column is chosen as the value. I looked at the code and found that the same code (below) is added for both of the cells in the editor template:

Code<code><!--[if $mode == "create"]-->

<!--[assign var="inputValue" value=""]-->

<!--[else]-->

<!--[assign var="inputValue" value=$game.teamid]-->

<!--[/if]--></code>


The same is essentialy true for the display template. Also the pntables file tries to add two columns to the Games table. So; is there something I am missing or is this a bug? I would have thought that the name of the relationships should be used for the column names and the field names of the classes?

I am also, as mentioned, a bit confused about the directions of the arrows. For one to many relationships it seems as if the direction is what I expect; a season is composed by n games so a one to many relationship pointing from Season to Game in the diagram does the trick. However it is opposite for the 1:1 relationships. Again this may be my UML background that gets me confuses (haven't drawn ER-diagrams since university).

Another thing, more of a feature request: for relationship values is it possible to have the tool generate dropdowns for the relationship values? For instance, for the Team<->Game example mentioned above when creating a new game it would be nice if the editor showed a dropdown for the homeTeam and awayTeam columns and allowed one to choose from the available teams in the Team database.

So; keep up the great work. I will continue testing !

Regards

Tor Neple


Options

Rating

Replies

  • Axel / Apr 24, 2008 / 04:00 Link to this post

    Axel

    Hello icon_smile

    neple
    Hello, firstly: thanks for great work on Modulestudio. I have been working on MDD for years now (Model to text transformations), and lately with GMF and the idea to use this to create a visual way of creating PN modules is brilliant!!!

    Nice to get feedback from people from this area. There will hopefully be other generator cartridges in future. In the long term ModuleStudio could support other frameworks as well as other platforms, depending on whether they can be described with the MVC-like DSL.

    neple
    I looked at the code and found that the same code (below) is added for both of the cells in the editor template.
    ...
    So; is there something I am missing or is this a bug?

    Yes, it is a known bug that multiple relations between the same tables are not processed correctly by the generator at the moment. I also saw that at the model for the new PN extension database, made the field names unique manually.

    neple
    I would have thought that the name of the relationships should be used for the column names and the field names of the classes?

    Hmmm, have to think about that as this would also require new validation rules (which is not really a problem, but has to be considered). However, relations are going to have a boolean attribute to allow inheriting the foreign key. Perhaps multiple relations could solved in a similar way by introducing an optional attribute (something like "namePrefix" or "namePostfix").

    neple(bwt quite the opposite of what I am used to from UML)
    ...
    I am also, as mentioned, a bit confused about the directions of the arrows. For one to many relationships it seems as if the direction is what I expect; a season is composed by n games so a one to many relationship pointing from Season to Game in the diagram does the trick. However it is opposite for the 1:1 relationships. Again this may be my UML background that gets me confuses (haven't drawn ER-diagrams since university).

    I do not count on UML because it is rather limited/restricted compared to an own DSL. I see your point, but let my explain the reason for the design: I wanted to treat 1:1 and 1:n in the same way in another perspective. If one customer has many orders, then every order gets a customerid. And if one customer has one address, then every address gets a customerid (and this is the point where it could be switched certainly - does it make more sense to store an addressid with every customer?). So in ModuleStudio there is a simple rule regarding persistence relations: the id will be on that side where the arrow points to - IIRC like in ER-diagramms. This is probably worth to get more documented.

    neple
    Another thing, more of a feature request: for relationship values is it possible to have the tool generate dropdowns for the relationship values? For instance, for the Team<->Game example mentioned above when creating a new game it would be nice if the editor showed a dropdown for the homeTeam and awayTeam columns and allowed one to choose from the available teams in the Team database.

    Sure it is possible - and at least some parts of it are already in the generator. I suggest you to send me your model (info@modulestudio.de) if you want it to be generated with a few bugs fixed and some minor enhancements.

    neple
    So; keep up the great work. I will continue testing !

    Thanks.


How to set up relations

8 Replies
Axel on May 15, 2012 - 06:04



Neue Umfragen

You have not voted in the poll:
What should be improved in future?
 
 
 

ModuleStudio Honey

Close

You don't have permission to e-mail this story - please login