Desktop version

Home arrow Computer Science arrow Object-Oriented Analysis and Design for Information Systems Modeling with UML, OCL, and IFML

Source

Partition

In Figures 6.30 and 6.31, the multiplicity 1 or 0..1 on the right side of the figure means that the association is a mapping, that is, for each value of the key there is at most one instance of the qualified class.

What if instead of “1” or “0..1” the multiplicity was marked with “*”? In this case, the association would read as follows: “for each key there is a set of instances of the qualified class.”

For example, books may be classified by genre. As many books may belong to the same genre, the genre attribute may not be unique. But it is possible to define a partition on the set of books based on their genre, as shown in Figure 6.32.

FIGURE 6.32_

An example of a partition.

_

FIGURE 6.33_

An example of a relation.

Figure 6.32 states that for each particular value of genre there is a set of books (with zero or more elements). The role multiplicity 1 on the left side indicates that every book has a genre.

Relation

Now, imagine that a book may have more than one genre, as, for example, The Hitchhiker's Guide to the Galaxy (Adams, 1979), which can be classified both as science fiction and humor. For representing the possibility of a book having more than one genre in the example of Figure 6.32, it would be sufficient to change the multiplicity on the left side of the association to * (if a genre is optional) or 1..* (if it is mandatory). Additionally, the genre should be removed from the attributes of Book, becoming an external qualifier, because the genre attribute should allow multiple values. Figure 6.33 shows the resulting relation.

The relation of Figure 6.33 states that a book may have one or more genres and a genre has a set of books associated with it. As a book may have more than one genre, then the qualifier should be necessarily external.

 
Source
Found a mistake? Please highlight the word and press Shift + Enter  
< Prev   CONTENTS   Next >

Related topics