association owned by classifier and association owned by relationship in UML

Chriss

I hope this simple example helps.

Guess you have a Java class

public class A {
   private B b;
   ...
}

In UML you would model this relationship as an association from A to B:

A -> B

with the following modeling elements:

Class B
Class A
  + Property b : B [0..1]    (owned by the class)
Association A_to_B
  + Property from_a : A [1]  (owned by the association)

Where the association A_to_B would have 2 association (member) ends referring two the properties showed above (A::b and A_to_B::from_a):

Now, let's think the following situation

public class A {
   private B b;
   ...
}
public class B {
   private A a;
   ...
}

In UML, you could the model the association (navigable in both ways) between A and B:

A <-> B

Whose model elements would be:

Class B
  + Property a : A [0..1]  (owned by the class)
Class A
  + Property b : B [0..1]  (owned by the class)
Association A_B

Where the association A_B would have 2 association (member) ends referring the two the properties showed above (A::b and B::a).


  • Before other things you should understand what the association A to B is.
    • Basically it is a solid line between A and B. It can represent one structure that connects class/instanc(es) of A with the class/instances of B. The structure can be of any sort and belong anywhere. All information, written about the line, describes this structure.
    • If there are two structures, one structure, that connects one instance of A with instance(s) of B and another structure that connects instance of B with instance(s) of A, you can show them both in ONE association. Then, information written about its B end describes the first structure (b->a) and info about the other end describes the other structure.
    • If you'll have more than one structure guiding from A to B, you have to draw two different associations.
    • If a joining structure is complex, you could represent it as an Association Class. There you can define more details.
    • A joining structure can connect more than two classes, then it will be shown as a large diamond with solid branches to these classes. It is still association! Attention: these two more complex associations are very badly supported by existing tools. You can easily create something absolutely senseless with them. And they are difficult. Use carefully.

example Class diagram


In C++ instance A can have the B instance not by pointer, but directly. There is NO special UML sign for it, it should be shown in the same way as normal, pointer attribute.