Compositions

 

Model and relational

The mapping of compositions in a relational model is optimized with regard to the general case of an association.  This specific mapping allows you to save space in the database and to improve performance when loading tables into the memory.

 

Figure 42. Example of a composition

 

 

Generated tables

 

Figure 43. Example of a composition

 

Curve (idCurve, measure)

Point (idCurve, idPoint, abscissa, co-ordinates)

 

The association is materialized by copying the primary key(s) of the aggregate class, here "Curve", into the table of the class which has the role of component, here the "Point" class.

 

"Component" type objects are always handled through the "aggregate" class.  The addition, removal and update of objects which are components of a composition is carried out by modifying "aggregate" objects in the memory, and by asking for an update of this object in the database.

 

 

Application domain

This optimized mapping of a composition, a special instance of an association, cannot be applied in the cases detailed below:

·         The "component" class of the composition cannot belong to a generalization graph except as a root class.

·         The "component" class cannot be component of more than one class.

When one of the clauses is not respected, the mapping of general associations will be adopted.