N Associations

This example is worked out here.

How do we determine the number of instances we need in the general case? The procedure above can be followed for each class that is in more than one association. Where two of these classes are associated, their sizes are adjusted with respect to each other, and then the numbers of instances of classes associated with them are adjusted.

Figure 3 shows five associated classes. A, C, and E each have one association, B has three associations, and D has two associations:

Figure 3: Multiply Associated Classes

There are two classes with more than one association: B and D. Above, we found the number of instances for with B. To find the instances for with D, calculate LCM(D) = LCM(5,3) = 15. Then

  • size(B) = 3*15/5 = 9
  • size(D) = 15
  • size(E) = 2*15/3 = 10

Together, the groups associated with B and D are:

B: 4A, 6B, 9C, 10D

D: 9B, 15D, 10E

To reconcile B and D,

  • Calculate the greatest common denominator (GCD) of the sizes for either B or D in the two groups. Choosing B arbitrarily, we have GCD(B)=GCD(6,9)=3.
  • Find a multiplier, by dividing the chosen size in each group by the GCD:
    • MB = 6/3 = 2
    • MD = 9/3 = 3
  • Then for each of B and D, multiply the values in group B by MD, and those in group D by MB.

The result is:

B: 12A, 18B, 27C, 30D

D: 18B, 30D, 20E

or, combined,

12A, 18B, 27C, 30D, 20E