Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One-Way Association with Multiplicity UML

I am trying to understand this certain case:

 ---------                ---------
|         |0..*      0..*|         |
|CLASS  A |------------->| CLASS B |
|         |              |         |
 ---------                ---------


 ---------                ---------
|         |1..*      0..*|         |
|CLASS  A |------------->| CLASS B |
|         |              |         |
 ---------                ---------

What I understand from the first example is: One Object from Class A has a relationship to zero or more Objects from Class B. That makes sense, because Class A knows Class B. But what exactly does the other multiplicity mean? Class B doesn't know Class A, so it doesn't seem to make sense to put a multiplicity there.

Same goes for the second example.

If someone has a good explanation, I would be very thankfull.

Greetings, john

like image 751
EeEmDee Avatar asked Oct 27 '25 14:10

EeEmDee


1 Answers

In fact it makes sense as it expresses a constraint on your (data)model.

By setting the multiplicity to [1..*] on the A side, you state that there should always be at least 1 or more instances of A that have a relationship to B.

When writing (or generating) business code this constraint is usually not enforced, but that is only one application for a UML model.

It also serves as functional documentation, where I'm definitely interested in the multiplicities on both sides.

This type of information is also crucial when designing a database. It will determine if the FK field will be nullable or not.

like image 52
Geert Bellekens Avatar answered Oct 29 '25 07:10

Geert Bellekens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!