Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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
add comment

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.