Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an association class in draw.io?

Tags:

uml

draw.io

I've started using the website draw.io, I want to create a class diagram but I couldn't find how to create an association class, any help would be useful. Thanks.

like image 369
ziMtyth Avatar asked Oct 12 '25 07:10

ziMtyth


2 Answers

The accepted answer is far to be perfect. In Draw.io (now called Diagrams.net), you can connect two shapes (here classes) with a connector but you cannot connect two connectors together.

Consequently, with the given solution, it will look like an association class but the dashes will not be really adjusted :

enter image description here

And really worste, if you need to re-arrange your diagram, the association link will not move and you will have to re-adjust it manually :

enter image description here

So, as it is sadly not possible to have a 100% satisfying solution for an association class, another solution is to turn the association class as a regular class. Here in the example, the OrderLine class is associated with both Order and Product classes. It is worth to note the migration of the multiplicities. Refactoring a class association as such an association will ALWAYS lead to have a 1 multiplicity for the non-association classes (here Order and Product), and the original multiplicities will be moved to the association class (here OrderLine).

enter image description here

like image 184
StratocastFlo Avatar answered Oct 13 '25 20:10

StratocastFlo


draw.io is a drawing tool, not a UML tool.

As such you can simply draw two class shapes, connect them with an association shape, then draw a third class as you association class and then use an association shape to connect you association class to the association.

Then go into the properties of the last association shape and change the line style to dashed.

Now it looks like a valid UML Association class, but I think you should really opt for a real UML tool instead of a drawing tool when you want to do anything with UML. Using this tool is similar to writing Java with MS Word.

like image 27
Geert Bellekens Avatar answered Oct 13 '25 20:10

Geert Bellekens