I have a question on many to many relationships and how to implement it in PHPRunner.
After a lot of thinking, swearing and searching the forums I did not end up with a satisfactory answer, that's why I am posting this question again in the hope to get an answer.
This is a very basic question and essentially has nothing to do with PHPRunner because it is a general database design issue.
But we happen to be (novel/experienced) PHPRunner web application designers who want to implement this with our favorite software package.
A good answer is very valuable because this kind of relationships is essential in applications that make extensive use of databases.
And if the answer is valuable, it should be included in the tutorial and tips and tricks, and the poster should get an award because he will save many hours of suffering.
Here is a small list of conditions the solution should comply with:
- Logical
The database design, form design, views, lists, etc should be designed logically to reflect the relationship.
General tips on how to design stuff are also very welcome.
- User friendly
All data is visible to the user in a such a way that the relationship is clear and the data is presented in a human readable fashion.
Low level stuff should be hidden to the user, data input and exploration should be intuitive without knowing a lot about the hidden stuff.
- Implementable in PHPRunner
I would like to use as many PHPRunner constructs as possible: scripts, events, design tools,... to implement the relationship.
Programming is not that much an issue, some PHP and/or javascript is not a problem.
- General
The solution should be general.
I would like to challenge you all to propose a solution to this question.
I am sure that a lot of the PHPRunner users will be very happy and grateful, at least I will be.
Other comments, additions, remarks, etc. are also welcome
To keep it fun, let's have the example of Belgian beers. We have several brands which are sold by several pubs.
All pubs are also selling several brands, a classic many to many relationship.
To follow good database design practise, we need a third table linking the beers and pubs tables.
Table Beer
beer_id beer_name
001 Gentse Tripel
002 Leffe
003 Augustijn
004 Westmalle
005 Westvleteren
006 Hoegaarden
007 Stella Artois
Table Pub
pub_id pub_name
A01 The Corner
A02 The Red Horse
A03 The Cyclist
A04 At the Abbey
Table beer_pub
beer_id pub_ID
001 A01
001 A03
002 A01
002 A02
002 A03
002 A04
003 A02
003 A03
003 A04
004 A03
004 A04
005 A03
006 A01
006 A02
006 A04
007 A02
007 A03
offtopic: Westvleteren is the best beer in the world (http://www.ratebeer.com/RateBeerBest/bestbeers_012010.asp)