This topic is locked

Many to Many, again

11/1/2010 8:11:10 PM
PHPRunner General questions
K
kenlyle author

Sorry, I still don't see a definitive answer after going to Google to search the forum (many to many doesn't find anything in the forum search), and looking through two pages of results.
Searched the 5.1 doc as well...5.2 Help only discusses one to many...
At http://www.asprunner.com/forums/topic/2527-can-phprunner-generate-many-to-many-relationships/ , Admin says that it's correct to have an intermediary table between Authors and Books, and elsewhere someone says you have to do something in the SQL, but I am not sure what.
So I have Products, Categories, and a ProductsCats table with little more than the foreign keys.
What's the general solution to displaying the master-detail in either direction with the intermediary table implied, but not shown?
Thanks,

K

Sergey Kornilov admin 11/1/2010

Here is a great article that worth reading:

http://www.databasedev.co.uk/many_to_many_example.html
Specifically it says:

A many-to-many relationship is really two one-to-many relationships with a junction/link table.

K
kenlyle author 11/2/2010

Yeah, that's exactly my situation, with my ProductsCats table.
But the Master-Detail can't be directly between Products and Cats, in either direction. So, is the trick to join the Master table to ProductsCats first, and use that View(?) as the Master? So, a ProductsMasterQuery with the CatID appended by a join as Master, then Cats as detail and vice-versa? I'll try it, but even if it appears to work, I'd like to confirm that it's the correct solution.
Sorry if I missed the definitive answer, but I did a good bit of searching...
Thanks,

K

Sergey Kornilov admin 11/3/2010

The definite answer is in the article I've mentioned. Many-to-many relationships are always implemented as a pair of Master-Details relationships. It's not specific to PHPRunner but rather a general relational databases theory.