JeeWiz Home  
The Model-Driven System Builder
JeeWiz Modeler's Help File for RSA/RSM
 
Contents  >   3.  The Persistence Tier
 


3.6 Modeling Many-to-Many Relationships

There are several ways to model a many-to-many relationship, and because of the different way they are stored in the emx file, you need to only use those forms accepted by the JeeWiz transform. If the link has no data associated with it, you can just draw the association as you would expect, a single line from one entity to the other. This will create a link table containing only the keys, and will allow maintenance screens to link or unlink the entities. If you want to specifically name the link table, this can be found as a JeeWiz property of the relation.

If there is data associated with the link itself you should resolve the many-to-many to a one-to-many and many-to-one. This means modeling the link table explicitly, and allows data to be maintained.

When working with dataviews, we may want to create pages that work either way, letting us link or unlink the entities, or letting us maintain the data on the link entity. So it is possible to doubly link the entities, both as a single line and through the explicitly modeled link table. By using the direct association the linking and unlinking can be handled, and by using the indirect association the data maintenance can be handled.

To do this the table names backing the association and the explicitly modeled link entity must be the same. You may also need to ensure that the keys are modeled to be the same. If the table is being newly created by the model, depending on your application server it may be necessary to generate first with only the explicitly modeled table, and then regenerate with the direct link added. This is because if the table as modeled by the direct link is used to create the table, it will have no data attributes specified, just the keys, whereas if the explicitly modeled entity is used to create the table it will have both data attributes and keys. So to avoid a 50-50 chance of building the table to the wrong specification, you can generate first with no direct link, or you can create the table using SQL (treating it like a legacy connection).


Top Tips:
  1. Decide first if your link is likely to need data, and model accordingly.
  2. To get maximum flexibility, be aware of the underlying link table.

Links:  

Copyright © 2001-2006 New Technology / enterprise Ltd.