How can I use a bridge table in WebRatio Platform?

17 Nov '17, 09:23 AM
No Forum Badges

Hi all,

I have a N-N relationhip between to entities. I need to add some information to this relationhip (e.g. an attribute storing the "order").
How can I add an attribute to a N-N association, which is a bridge table on my database?

x 0
Answer Answer at this question and get points!
Forum Expert - Level 8


in a ER diagram like the Domain Model, a relationship which has attributes can be modeled only through an Entity.
Thiis entity, which corresponds to the bridge table, has two outgoing 1-N relationships.
Each 1-N relationship represent a foreign key column of your bridge table.

You need to do the following steps to import a bridge table as entity:

1. Delete the N-N relationship
2. Synchronize the database and import the bridge table
3. Set the two foreign key columns as the primary key of the entity
4. Draw two 1-N relationships connecting the new entity with the ones connected through the old N-N relationship. 
The 1 cardinality is referred to the role of the relationship that has as target the new entity.
5. Map manually the two 1-N relationships using the existing columns of the bridge table as the foreign keys and the oid column of other entity as oid.
6. Execute the Find Model Problems command on the Domain Model to be sure that everything is properly set.

Remember that changing the Domain Model has consequences also in the Web model. 
In particular you have to change all components using the old N-N relationships.
There are mainly three things to do:

a. replace all the connect operations based on the old N-N relationship, if any, with create operations based on the new entity
b. replace all the disconnect operations based on the old N-N relationship, if any, with delete operations based on the new entity
c. replace all the relationship role conditions that used the old N-N relationship, if any, with a relationship role condition based on one of the 1-N relationships you have added before. 
The choice between one of the two relationships depends on the entity used by the component on which the conditional expression is applied. 
Moreover you have to explicitely extract the instances of the new entity sutisfying the old N-N relationship using a selector operation and connect this component to the component having the conditional expression.

x 0
Forum Expert - Level 5


To enter the information in bridge tables you must use the components:

- Connet, Save data

- Disconect, Delete data

- Reconnect, both

Using a Source and target data

x 0
Answer at this question and get points!