Understanding UML Class Diagram Relationships

While you are sure to have found the video post we did on How to draw Org Charts with Creately interesting and useful, we thought of visiting the subject of Class Diagrams and the relationships  that exist between classes in this particular post. In a class diagram, obviously you can’t have classes just floating around; you need to see the relationship between them. Many have trouble understanding class diagram relationships, which is understandable because there are quite a few that look similar. Pursue the content below to see the types of relationships that exist between classes, along with their notation, and also what they actually mean.

1. Association

An association relation is established, when two classes are connected to each other in any way. For example: A “bank registers account” association can be shown as follows.
Association relationship in class diagrams

2. Multiplicity

An example of this kind of association is many accounts being registered by the bank. Hence, the relationship shows a star sign near the account class (one to many and many to many etc). When it comes to class diagram relationship this is one of the most misunderstood relationships.
Multiplicity relationship in Class diagrams

3. Directed Association

By default, an association that exists between classes is bi-directional. Ideally, you may illustrate the flow of the association by utilizing a directed association. The arrowhead indicates the container-contained relationship.
Directed Association in Class diagrams

4. Reflexive Association

An example here is when a class has many different types of responsibilities. For example, an employee of a company can be an executive, assistant manager, or a CEO. There is no symbol that can be used here, however, the relation will point back at the same class.

5. Aggregation

When a class is formed as a collection of other classes, it is called an aggregation relationship between these classes. It is also called a “has a” relationship.
Aggregation Relationship in Class Diagrams

6. Composition

Composition is a variation of the aggregation relationship. Composition illustrates that a strong life cycle is present between the classes. Another class diagram relationship that not many are aware of and few really understands.
Composition Relationship in Class Diagrams

7. Generalization/Inheritance

Known as an “is a” relationship since the child class is a type of the parent class. Generalization is the ideal type of relationship that is used to showcase reusable elements in the class diagram. Literally, the child classes “inherit” the common functionality defined in the parent class.
Generalization Relationship in class diagrams

8. Realization

In a realization relationship, one entity (normally an interface) defines a set of functionalities as a contract and the other entity (normally a class) “realizes” the contract by implementing the functionality defined in the contract.
Realization in Class Diagram Relationships

Pre-set connector types

There you have it, 8 relationships that exist between classes. Drawing and designing Class Diagrams is a real real cinch with Creately. Thanks to the varied specialist features (see screen shot below) present on the app, UML design is an efficient and east endeavor.

Questions about Class Diagram Relationships and More Information

We do encourage you to check out our repository of information on UML design while we would also be more than glad to answer any questions or doubts that you may have.

Tags :, , , ,

About the Author

About rohitha

Rohitha Perera is a Community Evangelist at Creately.com, a collaborative diagramming software for teams. When he’s not working on marketing strategies for web start-ups, he spends time reading, watching movies, jogging, gardening and cooking. You can follow him on Twitter:@creately @ForzaRP

2 thoughts on “Understanding UML Class Diagram Relationships

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This blog uses premium CommentLuv which allows you to put your keywords with your name if you have had 9 approved comments. Use your real name and then @ your keywords (maximum of 3)