MSc-IT Study Material
January 2011 Edition

Computer Science Department, University of Cape Town
| MIT Notes Home | Edition Home |

Specifying relationships in detail

If a link is drawn as a simple line, it is assumed to be a one-to-one association. In the previous example this would mean that each member of the library can borrow exactly one book, and each book can be borrowed by exactly one member. This is probably not correct. It is good practice to indicate on each end of the link its multiplicity, that is, the number of objects associated with the link. It is particularly important to distinguish between 1 and many in multiplicities.

We could re-draw the previous example like the figure on the left:

Figure 5.3. Indicating multiplicity

Indicating multiplicity

This indicates that at any given time a LibraryMember is involved with a borrows association with an object of class Book, that is, a library member can borrow up to six books. At the same time, a book can only be on loan to one member.

The figure on the right is an example of a many-to-many relationship. A student can be studying one, two, or three courses at a particular time. Each course can be studied by an indeterminate number of students. The symbols M stands for many, and means some unspecified number. The asterisk (*) can also be used to stand for many. Note that the UML distinguishes a many that may include zero from a many that does not. In the students example, the number of students enrolled on a course varies from zero up to many, not from one up to many.

The multiplicity symbols are an example of what the UML specification calls end ornamentation. End ornaments are symbols that can be used on the ends of associations to enhance their meanings. Another common end ornament is the navigability arrow. This is an arrow drawn on (not alongside) the line and indicates the direction in which the class structure can be traversed for information.