If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Alternative many to many approach

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-15-08, 06:23
tonykok tonykok is offline
Registered User
 
Join Date: Apr 2008
Posts: 4
Alternative many to many approach

Hi !!
When a many to many relationship is required, the linking table is the only way to go or does any other option exists?

Suppose the following scenario

One author - One book (90 %)
One author - many books (8 %)
Many authors - One book (2 %)

Could the following design be an option or is it totally wrong?

Alternative many to many approach-authorsbooks2.jpg
Reply With Quote
  #2 (permalink)  
Old 04-15-08, 06:59
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
the linking table is the best way to go

your diagram doesn't really convey the idea of a working many-to-many scenario

perhaps you could illustrate how it works by showing us a few rows of data from each table
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-15-08, 07:52
tonykok tonykok is offline
Registered User
 
Join Date: Apr 2008
Posts: 4
Authors and books are not the entities in the real scenario but my english is not good enough to describe exactly the real scenario.

Here are the rows for authors table
Alternative many to many approach-authorsrows.jpg

and for books table
Alternative many to many approach-booksrows.jpg

In the real scenario the entityB (books) will be autogenerated by EntityA (Authors). This will happen only once. So having bookID in the Authors table will restrict author of collaborating more than once but in my case this is not a problem. The entities A (authors) already exists in the table. My programm is going to insert mostly (98%) entity B rows in the Books table. The rest 2 % of entities B that are result of collaboration are going to modify the EntityA (Authors) Table.
Reply With Quote
  #4 (permalink)  
Old 04-15-08, 08:01
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
it is an incomplete many-to-many relationship, specially crippled for your particular needs -- an author can collaborate only once

i would nevertheless still use a proper relationship table

what you should do is write the queries that your application will need to retrieve information

see if the sql is simpler

i'm guessing it will more complex
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 04-15-08, 08:32
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
That is a REALLY bad design.

I predict you will end up duplicating authors and/or books across several records.

Use a many-to-many table.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #6 (permalink)  
Old 04-15-08, 08:50
tonykok tonykok is offline
Registered User
 
Join Date: Apr 2008
Posts: 4
It's not really the time for experiments. I'm going the proven way. Though I was wondering if anyone had used this approach.

Thank you for your time.
Reply With Quote
  #7 (permalink)  
Old 04-15-08, 09:04
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Its cool to experiment, but not when there is any sort of deadline looming.

Try your schema in your spare time, and you will see what its drawbacks are and learn a lot from playing around with it.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On