jc2006 Posted December 12, 2006 Share Posted December 12, 2006 HiI have a problem with table design.Is it possible to have many to many relationships between 3 tables?I have a unique situation as follows:table 1 --- many to many table --- table 2 | | table 3Is such a scenario possible?ThanksJ Quote Link to comment https://forums.phpfreaks.com/topic/30366-solved-many-to-many-relationships/ Share on other sites More sharing options...
The Little Guy Posted December 12, 2006 Share Posted December 12, 2006 So.. Whats the problem your having, or why do you ask this? Quote Link to comment https://forums.phpfreaks.com/topic/30366-solved-many-to-many-relationships/#findComment-139846 Share on other sites More sharing options...
jc2006 Posted December 12, 2006 Author Share Posted December 12, 2006 Sorry, I guess I wasn't specific enough. Here's an example:Table 1 lists restaurants: A, BTable 2 list customers: M, NTable 3 lists food: X, YTable 4: is the many to many relationship between restaurants and customers.I'll call it restaurants_to_customers.A --- MA --- NB --- NTable 5: is the many to many relationship between customer and food.customers_to_foodM -- XN -- YTable 6: is the many to many relationship between restaurant and food.restaurant to food.A--XA--YB--YA given customer "N" can eat at a given restaurant "A." And, customer "N" may have eaten a meal "Y" before. But because of tables above, is there a way to determine if he ate meal "Y" actually AT restaurant "A" or at a different restaurant "B"?Put another way, if I listed all the places customer "N" ate at it would include restaurant "A" and "B." And since both these places serve meal "Y" is there any way to know if the customer actually ate the meal "Y" at these restaurant A or B? Wouldn't it be easiest to create a many_to_many relationship between restaurants, customers, and meals? I don't think this is possible though. Or is there a better solution?I apologize in advance if my explanation is convoluted and makes little sense.Thanks Quote Link to comment https://forums.phpfreaks.com/topic/30366-solved-many-to-many-relationships/#findComment-139912 Share on other sites More sharing options...
artacus Posted December 13, 2006 Share Posted December 13, 2006 Yeah you got it. Add another table, dining_events (I'm sure you can think of a better name) that says on this day, this person ate this meal at this restaurant. Quote Link to comment https://forums.phpfreaks.com/topic/30366-solved-many-to-many-relationships/#findComment-140266 Share on other sites More sharing options...
jc2006 Posted December 13, 2006 Author Share Posted December 13, 2006 thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/30366-solved-many-to-many-relationships/#findComment-140684 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.