Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UML class model how to model many to many relationship

I have read several tutorials on what a UML model should contain and what not. As a developer I always think in terms of a relational data model where you could never have a many to many relationship between tables. Now with a UML class model, I've read that if they don't provide added value, you could just skip the linktables.

However I've also read a tutorial where examples where given using data inside tables and was strongly suggesting to picture each class as a simple table while modeling your class model.

I am confused, what is it now?!

like image 322
Peter Avatar asked Aug 20 '09 13:08

Peter


1 Answers

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?

like image 110
S.Lott Avatar answered Oct 23 '22 13:10

S.Lott