I never understood the difference between these types of association. How should I interpret and in which scenarios should I use each one?
The first one is a named association. The name of the association (being purchase
) is pretty pointless unless you are doing some exotic stuff. In this case User
and Product
have both some array referencing objects on the other side.
The second and third are just alternative notations for the same thing. That is you have an association class Purchase
which in this case connects User
and Product
by adding some (not shown) functionality/attributes. Here the classes left/right do not see each other. It's only Purchase
which makes the references.
Edit As noted by @JimL. the 2nd and 3rd differ in one respect: #2 has two*
left and right where there should be a 1
to make it a match for #3. This would be the usual use for an association class. The *
would make it different and probably very uncommon for the obvious application here.