Java Reference
In-Depth Information
T389
ShellAssembler-2301
T001
Fuser-2101
T002
Fuser-2101
Consider the rubber tubs of chemicals at Oozinoz. Tubs are always assigned to a particular
machine. You can model this relationship with a table, as Table 10.1 shows. Recording
relational information in a table lets you preserve relational integrity. In Table 10.1, keeping
the Tub column unique guarantees that no tub can appear on two machines at once.
Table 10.1 shows the relation of tubs and machines—the way in which they stand with
regard to each other. Mathematically, a relation is a subset of all ordered pairs of objects, so
there is a relation of tubs to machines and a relation of machines to tubs. See the sidebar
Relational Integrity on page 108 for a more strict definition of relational consistency in an
object model.
When you record tub and machine relational information in a table, you can guarantee that
each tub is on only one machine by enforcing the restriction that each tub occurs only once in
the Tub column. The most common way to do this is to make the Tub column the primary key
of the table in a relational database. With this model, as in reality, a tub cannot appear on two
machines at once. In an object model, such a guarantee is more difficult to make, because
the relation information is distributed to the modeled objects, as Figure 10.4 shows.
Figure 10.4. An object model distributes information about relations.
The arrowheads in Figure 10.4 emphasize that tubs know about machines and that machines
know about tubs. In a typical implementation, each Tub object would have a Machine
attribute to indicate its current location, and each Machine object would have a list of Tub
objects representing tubs located at the modeled machine. The distribution of the tub/machine
relationship makes the management of the relationship more difficult and makes this
management a candidate for application of the M EDIATOR pattern.
Search WWH ::




Custom Search