Everything You Need to Know About UML Class Diagram Relationships

In a class diagram, obviously you can’t have classes just floating around; it is important that you see the relationship between them. Many have trouble figuring out 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 an example a “bank registers account” association can be shown as follows.

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 relationships, this is one of the most misunderstood relationships.

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.

4. Reflexive Association

A reflexive association is formed 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, the connection between these classes is called an aggregation relationship. It is also called a “has a” relationship.

6. Composition

Composition is a variation of the aggregation relationship. Composition illustrates that a strong life cycle is present between the classes. It’s another class diagram relationship that not many are aware of and few really understands.

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.

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.

Pre-set connector types

There you have it; 8 relationships that exist between classes. Drawing and designing Class Diagrams is a real cinch with Creately. Thanks to the varied specialist features (see screen shot below) present on the app, UML design is an efficient and easy 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.

This article is originally published on the Creately blog and has been slightly modified to match the guidelines provided by medium.com. Click on this link to read the original article;