Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 2 down vote accepted

You can use an association class as depicted e.g. here:

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).

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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