such as Hibernate, support this feature but on the
level of class: a class can be annotated as one whose
instances will be embedded into the instances of the
other class (on the other side of compositions).
However, it is important to understand that this is
actually a property of an association, not of an entire
class: in our practice, we have come across
situations in which it was very useful (according to
the usage of data) to have some instances of a
certain class, which are aggregated into other objects
over one composition, embedded into those other
objects, while the other instances of that class should
be stored in a separate table. Again, to the best of
our knowledge, we are not aware of any ORM or
publication that supports this feature.
The embedded Foreign Key and the Distinct
Table Approach (1:1): If properties of one class are
dominantly retrieved, while objects of the other class
are rarely accessed, then the normalized models 1
and 2 may be a better choice, since negative effects
of frequent joins are minimized, while the
normalized relation model responds better to further
changes in the model.
Mapping Associations 1:n
The Distinct Table Approach (1:n). This is the
most flexible way of mapping, but it requires
expensive joins if the relation is traversed
frequently. This approach provides the
implementation of the bidirectional navigability.
The embedded Foreign Key Approach with
Unidirectional Navigability (1:n): The embedded
key approach is the most convenient and efficient
for this kind of associations. The embedded foreign
key is incorporated into the table of the dependent
class. This saves one level of joins, while still being
flexible and keeps the relational model in a
normalized form. The problem with this approach is
that it does not provide the bidirectional navigability
(on the level of foreign keys, which are stored in
only table on the n side of the association).
The embedded Foreign Key Approach with
Bidirectional Navigability (1:n): As mentioned in
the case of the embedded key approach, it does not
provide bidirectional navigability (foreign keys are
stored in one table only). In a special situation, the
bidirectional navigability can be implemented even
without the distinct association table. We may use a
technique called repeating groups (Shin and Sanders,
2006). Namely, if the multiplicity of the dependent
class is low, and with specified maximum
cardinality, IDs of the dependent objects can be
incorporated as foreign keys in separate columns in
the owner object's record (Zaker, Phon-Amnuaisuk
and Haw, 2009). In our future work, we will be
experimenting with an ORM approach of
bidirectional navigability with unlimited maximal
cardinality.
The embedded Class Approach (1:n): In the
case of low multiplicity of the dependent class, it
may be useful to embed it to the table of the owner
class. Hence, joins are not needed for traversing the
association, all property values are available directly
in the owner object's record.
Mapping Associations m:n
The Distinct Table Approach (m:n): The distinct
table approach is a natural solution for persisting
links of this kind of associations. Each record of the
table contains pairs of object identifiers, for objects
from both sides of the association. Although
flexible, this approach requires two joins to retrieve
combined attribute values from the related objects.
On the other hand, updates remain fast and easy
(Agarwal, Keene and Keller, 1995).
Distinct Table Approach with Controlled
Redundancy (m:n): In the previous paragraph, we
mentioned that the distinct table approach requires
two joins to retrieve properties of the related objects.
Usually, applications need to retrieve only subsets of
the properties from the related classes. If the
property values are rarely changed, then it makes
sense to copy those properties that are accessed most
frequently to the association table. This way,
similarly to the hybrid approach of mapping
inheritance described before, we apply a controlled
redundancy to keep copies of properties that are
most often retrieved when the association is
traversed in the association table. This approach
eliminates join operations in these cases. As for the
similar approach for mapping inheritance, we are not
aware of an implementation or publication of this
mapping, that we propose.
The embedded Foreign Key Approach (m:n):
The embedded key approach may be considered in
the situation when the multiplicity on at least one
side is low, known and limited with the upper
bound. That way, the table of the class at the
opposite side may contain repeating groups of the
finite number of object identifiers as the foreign
keys (Shin and Sanders, 2006). Interesting to
mention, such a mapping improves performance of
queries that need to read direct links of an object. If
both association ends have low and limited
multiplicities, we may apply the same technique on
the opposite table, too. That way we get
bidirectional navigability, compared to the case
when only one role has low and limited multiplicity.
MODELSWARD2015-3rdInternationalConferenceonModel-DrivenEngineeringandSoftwareDevelopment
284