design model where reference properties represent associations. The following model for our
example app contains the multi-valued reference property
represents the unidirectional many-to-many association Book-has-Author:
The meaning of the design model and its reference properties
authors can be illustrated by a sample data population for the three model
Table 13.1. Sample data for
|Bantam Books||New York, USA|
|Basic Books||New York, USA|
Table 13.2. Sample data for
|0553345842||The Mind's I||1982||1, 2||Bantam Books|
|1463794762||The Critique of Pure Reason||2011||3|
|1928565379||The Critique of Practical Reason||2009||3|
|0465030793||I Am A Strange Loop||2000||2||Basic Books|
Table 13.3. Sample data for
Create a check operation for each non-derived property in
order to have a central place for implementing property constraints. For any reference property, no
matter if single-valued (like
Book::publisher) or multi-valued (like
Book::authors), the check operation (
checkAuthor) has to check the corresponding referential integrity constraint, which requires that all references
reference an existing object, and possibly also a mandatory value
constraint, if the property is mandatory.
Create a set operation for each non-derived single-valued property. In the setter, the corresponding check operation is invoked and the property is only set, if the check does not detect any constraint violation.
Create an add, a remove
and a set operation for each non-derived multi-valued property. In the
case of the
Book::authors property, we would create the operations
setAuthors in the
Book class rectangle.
Author, while the missing class
the same as in Figure 12.1:
Notice that, for simplicity, we do not include the code for all validation checks shown in the data model in the code of the example app.