![]() | MSc-IT Study Material January 2011 Edition Computer Science Department, University of Cape Town | MIT Notes Home | Edition Home | |
In many cases each instance of an association has properties of its own. It is sometimes helpful to show this in the model for increased expressiveness. In addition, it gives us a way to show that multiple classes are involved in the same association.
A link attribute simply assigns a value to a particular instance of the link, that is, for each pair of objects that are associated there is a particular value of the attribute. For example, in the top diagram of the figure shown below:
“transactionNumber” is a link attribute. This model says that the bank and its customers enter into transactions, and each transaction has a particular number.
However, the association may be too complex to be represented by a single attribute. In this case we can use a link class. With a link class there is one instance of the class for each pair of objects that are associated. The link class can have any number of attributes, and can quite legitimately enter into relationships of its own with other classes in the system. In the example above, the link class “Number” defines each transaction carried out by the bank with its customers. It has attributes to indicate the nature and date of the transaction, as well as the number. Link classes can also have sub-classes. For example, it may be useful to indicate that there are different types of transaction by means of sub-classes, rather than simply having an attribute called “type”.
Link classes are a very powerful and expressive tool, but do take some experience to able to use effectively.