Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UML association class - clarifying

I am reading "UML distilled" by Martin Fowler, and during reading about association classes I got this quote:

What benefit do you gain with the association class to offset the extra notation you have to

remember? The association class adds an extra constraint, in that there can be only one instance of

the association class between any two participating objects.

Then there was an example, but I want to make sure I got this right, if for example I got:

 ---------            ---------
|         |*        *|         |
| CLASS A |----------| CLASS B |
|         |     |    |         |
 ---------      |     ---------
                |
          ______|______
         |             |
         |             |
         |  CLASS C    |
         |             |
         |_____________|

then, for every distinct pair (instance of A,instance of B) there exists only one instance of class C.

So if I would take A1,A2,B1,B2-instances then for (A1,B1) (A1,B2) (A2,B1) (A2,B2) I would get 4 instances of C, nothing less, nothing more?

like image 322
Andna Avatar asked Oct 24 '22 06:10

Andna


2 Answers

From the UML 2.5 specification:

Note that when one or more ends of the AssociationClass have isUnique=false, it is possible to have several instances associating the same set of instances of the end Classes.

Mr. Fowler may have gotten the facts wrong. There is no extra constraint, just the ability to store additional property values.

When isUnique=false, extra properties allow one to model multiple visits to the same doctor on different dates, or multiple purchases of the same products on different dates, for example.

like image 118
Jim L. Avatar answered Nov 04 '22 21:11

Jim L.


That'd be correct, without any intention to mix concepts here but it's similar to Tables in a database where:

A 1-* C
B 1-* C

Where C can be seen as the result of breaking a many to many relationship between A and B.

For each row on B can only exist 1 and only 1 Row C and That Particular row (on C) can only me related to 1 row on A. Hence, for each Pair of unique rows on A and B can only exist 1 row on C or none, because the * indicates 0 or more.

like image 44
lmcanavals Avatar answered Nov 04 '22 20:11

lmcanavals