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

I am drawing a class diagram and I want to know what's the proper notation for many to many relationship between supplier and product?

Should I show the table created supplier_product or leave it out and have the relationship many to many between supplier and product?

I have seen various representations online.

share|improve this question
In the future darlene, do not post the same question twice. I went ahead and merged them this time. If you would like to revise your question you may click the Edit link below the question to provide new details. If you have questions then please ask on Meta or refer to the FAQ – maple_shaft Apr 4 '12 at 16:42

I annotate the line with "*..*". For 1-to-many it would be "1..*". It's a standard way of denoting multiplicity.

share|improve this answer
Formally, it's *..* for many-to-many and 1..* for one to many. The *s are required and it's two periods instead of three. This is called muliplicity. – Thomas Owens Apr 4 '12 at 16:35
Thanks, I forgot to escape the * character. – Garrett Hall Apr 4 '12 at 16:37

"I am drawing a class diagram ... Should I show the table created supplier_product ? "

The many-to-many relationship is part of your class design. The join table is not; it is created incidentally by the OR mapping framework. Include the relationship. Do not include the table, or any other generated artifact.

share|improve this answer

It depends on the business. On our business you can get the same spare part from multiple suppliers and each and every one has its own internal item code. So we have our own product item master which holds our code with the relative data.

Then there is the supplier master table with the suppliers.

Finally a Cross reference table exists where you bind one item with one supplier and provide the suppliers Description and item code.

so i suppose that in our case its a many to many relationship....

share|improve this answer

Your question is good because you are thinking of whether you need this table or not. That shows you care about the quality of your design.

The notation part has been fully answered by others, so I will focus more on the other part.

Should I show the table created supplier_product or leave it out and have the relationship many to many between supplier and product?

You need to find the answer not only from a technical perspective but also from a business perspective. For example, you need to ask a question like this:

  • Do I need to know when a supplier started supplying a product to the company?

  • Is the price of a supplied item depndent on the time or quantity supplied?

  • Is there a minimum quantity a supplier must supply per order that we need to know about?

  • Would there be associations between supplier_product to other classes in the model?

If your business has no interesting properties to place in the intersection table and there are no required associations (as in the above questions) and If you are doing the class diagram as part of high-level design from an OO perspective, you could do as @Kenvin Cline suggests and not include the class in your current version of the model.

If you want to be precise and clear and/or If you plan to implement the design at this stage in a relational database, either yourself or the application you'll use to create (forward engineer) the DLL will have to deal with the missing class representing the many-to-many relationship. Some tools could automatically create a Primary Key and FKs and RI constraints (of the tool's choice) and name all that in a way you may or may not accept. Also, your ORM mapper will have to create code to deal with this hidden table.

The effect of RI is critical and should always be checked and controlled. You need to precisely determine what happens to the supplied item information when a supplier is deleted from a database.

If you were doing a physical database design, then I would definitely suggest you flesh out your design and not let the tools do that for you unless you are entirely familiar with how and what the tools will build for you.

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.