The purpose of the app to be built is managing information about
movies. The app deals with just one object type: Movie
, as
depicted in the following class diagram.
In this model, the following constraints have been expressed:
Due to the fact that the movieId
attribute is
declared to be the standard
identifier of Movie
, it is mandatory and unique.
The title
attribute is mandatory, as indicated by its
multiplicity expression [1], and has a string length
constraint requiring its values to have at
most 120 characters.
The releaseDate
attribute has an interval
constraint: it must be greater than or equal
to 1895-12-28.
Notice that the releaseDate
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 the datatype PositiveInteger
to
movieId
, NonEmptyString
to title
,
and Date
to releaseDate
.
You can use the sample data shown in Table 8.2 for testing your app.
The purpose of the app to be built is managing information about
countries. The app deals with just one object type:
Country
, as depicted in the following class diagram.
In this model, the following constraints have been expressed:
Due to the fact that the name
attribute is
declared to be the standard
identifier of Country
, it is mandatory and unique.
The name
attribute has a string length
constraint requiring its values to have at
least 3 and at most 50 characters.
The population
attribute is mandatory, as indicated by the
multiplicity expression [1] appended to the attribute name.
The lifeExpectancy
attribute is also mandatory and has an interval
constraint: its values must be less than or
equal to 100.
Notice that the militaryExpenditure
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 the datatypes
NonEmptyString
to name
,
PositiveInteger
to population
,
PositiveDecimal
to lifeExpectancy
and
Percentage
to militaryExpenditure
(hint: a
percentage value is a decimal number between 0 and 100). In our Java
example app, such property constraints were coded in the entity class by
using the Bean Validation API.
You can use the sample data shown in Table 8.3 for testing your app.