UML class model how to model many to many relationship

The "relational link table" is an implementation technique for a Many-to-Many relationship.

The relationship exists irrespective of how it's implemented.

In an object model, you have many choices for how to implement many-to-many, which may (or may not) involve an additional persistent table. It could be done lots of different ways.

The point of UML is to be able to describe the essential features of what the model really is.

You can also describe the implementation. They're separate diagrams with separate purposes. You can easily show the relational implementation with the link table. You can also show the essential model without the link table.

Here's the essential relationship

Essential

Here's the implementation of the relationship

Implemntation

Both are valid UML. The real question is "what do you need to show other people?" Essential truth or one particular implementation?


Model it as an M:N relationship. Same as in a relationship model there will be an associate class (or link class) of some kind in code. No need to put that on the diagram unless it has attributes on top of the join attributes (much like you would generally omit a join entity from an ERD unless it had attributes that weren't foreign keys in the related entities). The link class is typically drawn as a class connected to the relationship by a dashed line.

The Enrolment join entity is a good example of this in UML 2 Class Diagrams.