1-1 associations

 

Pattern for taking into account associations of 1-1 type

Associations of 1-1 multiplicity can be transformed in two different ways:

·         By merging the two tables

·         By generating a foreign key on both sides

 

The first method limits the number of tables.  It consists of merging the two tables into one.  The primary keys of each of the modeled classes are assembled to create the primary key of the resulting table.  After model transformation, it is possible to delete the definition of a {primaryKey} tagged value, in order to limit the attributes used as the primary key of the table obtained.  In this case, subsequent transformation of the analysis model into the physical model will generate the attribute with an associated {primaryKey} tagged value.  Attributes should be annotated  {sqlDoNotUpdate}.  This transformation is effective if a role has the {sqlOptimized} tagged value. The destination table is then merged in the source table.

 

Depending on the model of the application, this first solution may not suit, because of the association(s) from these classes towards or from other classes.

 

The second method allows the generation of two distinct tables, and strictly respects the analysis model, by transforming each of the classes into a table stereotyped <<table>>.  In this case, attributes which define the primary keys of each of the two tables are generated in the other table as foreign keys.  This transformation is applied by default.