[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


What is the disadvantage for many to many table relationship

Posted on 2009-04-21
Medium Priority
Last Modified: 2013-11-16
If we do query from 2 tables which have many to many relationship, what will be the potential cause issue. and why ?
Question by:isnotaboutu

Accepted Solution

keith9820 earned 1000 total points
ID: 24198790
A normalized Many-to-Many (M2M) relationship typically uses 3 tables - two fact tables and a join table.  For example, if many copies of a given book may be sold at many book stores, you might design your M2M relationsip with these tables:

id (int)
title (varchar)
pubdate (datetime)

-- STORE --
id (int)
name (varchar)
address (varchar)
phone (varchar)

Book_id (int)
Store_id (int)

The only "downside" to doing this is that you might want to join the tables together when searching for stores that cary your book, and joins incur some overhead.  The upside is that since your book information and store information live in their own tables, you don't have to reapeat that stuff across many tables (which has an impact on the physical size of your database and therefore affects disc storage space).
 In a DataWarehousing system, you might "de-normalize" those 3 tables into one to make your queries perform faster since they wouldn't bother with any joins.

Author Comment

ID: 24198864
If we don't have a bridgae table to handle many to many table relationship, can we still get the correct information on query ?

Assisted Solution

agandau earned 1000 total points
ID: 24205724
Bear in mind that nearly every fact table in a data warehouse is that third table serving as the many-many relationship between dimensions tables.
In light of the example above, you likely won't find a table called "store has book", but you might have, say, a PurchaseOrder table that records that a book was ordered to be stocked in or shipped out of that store.  Then you might have another table called SalesOrder that records the book was sold out of that store.
In order to get an answer to your question, you may need to provide a few more details.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question