Which are the steps to follow in order to correctly import a bridge table in the data model?

From Wiki

Jump to: navigation, search

A N-N relationship in your data model usually corresponds to a bridge table on the database. When you realize that this bridge table has to provide other information you can easily add columns to the table directly from the database. The problem is the data model of the Web project. In a ER model like the data model, a relationship which has attributes can be modeled only thorugh an entity (corresponding to the bridge table) and two outgoing 1-N relationships (representing the two foreign key columns). These are the steps you can follow:

  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 as the foreign key the existing column of the new entity and as oid of the other entity its oid column.
  6. launch the warning on the data model to be sure that there aren't mistakes.

Importing a bridge table has consequences also in the Web model. In particular you have to modify all the units based on the old N-N relationship. There are mainly three things to do:

  • replace all the connect units based on the old N-N relationship with create units based on the new entity
  • replace all the disconnect units based on the old N-N relationship with delete units based on the new entity
  • replace all the relationship role conditions that used the old N-N relationship 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 unit on which the selector condition is applied. Moreover you have to explicitely extract the instances of the new entity sutisfying the old N-N relationship using a selector unit and connect this unit to the unit having the selector condition.
Personal tools