Table of Contents
We again consider the single-class data management problem that was considered in Part 1 of this tutorial. So, again, the purpose of our app is to manage information about books. But now we also consider the data integrity rules (also called 'business rules') that govern the management of book data. These integrity rules, or constraints, can be expressed in a UML class diagram as shown in Figure 6.1 below.
In this model, the following constraints have been expressed:
Due to the fact that the
isbn attribute is declared to be the standard identifier of
Book, it is mandatory and unique.
isbn attribute has a pattern constraint requiring its values to match the ISBN-10 format
that admits only 10-digit strings or 9-digit strings followed by "X".
title attribute is mandatory, as indicated by its multiplicity expression , and has a
string length constraint
requiring its values to have at most 50 characters.
year attribute is mandatory and has an interval constraint, however, of a special form since the maximum is
not fixed, but provided by the calendaric function
nextYear(), which we implement
as a utility function.
Notice that the
edition attribute is not mandatory, but optional, as indicated by its multiplicity expression [0..1]. In addition to the
constraints described in this list, there are the implicit range constraints defined by assigning
NonEmptyString as range to
encoded in the model class within property-specific check
The meaning of the design model can be illustrated by a sample data population for the model
Table 6.1. Sample data for
|006251587X||Weaving the Web||2000||3|
|0465026567||Gödel, Escher, Bach||1999||2|
|0465030793||I Am A Strange Loop||2008|