As we know a many to many association are shown by two asterisks in both end of association. Now I have a association between two entities "Good" and "Invoice" so Good and Invoice have a many to many association but I want to show the "count of each good" in each invoice on class diagram.

How can I show it?

2 Answers 2


You can use an association class as depicted e.g. here: http://www.agilemodeling.com/style/classDiagram.htm

Using a new class and two associations inbetween like user1598390 described is valid as well. It depends how you would like to see the relationship between your entities. UML-wise association classes are probably more concise. Regarding the implementation in a programming language both solutions might even look the same (implemented with an additional link object as most programming languages don't support attributed links or pointers).


Often times many to many associations indicate the need for a third entity.

You need InvoiceDetail entity.

Anyway "count of each good" should be a method in class Invoice.

public int getCountOfGood(Good good);

there can also be a method that returns a data structure with the count of each distinct Good in the Invoice

public Map<Good><Integer> getCountOfEachGood();

Good entity is oblivious of Invoice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.