I have two entities that usually have one-to-many relationship, but in rare cases should have an opportunity to be many-to-many. I don't want to join the tables with the intermediate table for every query - and i guess there are preferable patterns for "rare many-to-many", - (perhaps with additional table for m-t-m, with duplicate records or something). Any ideas?
UPD. Well, first of all i think about potential overhead with intermediate table (maybe i overestimate it), the second is about expressing real-world semantic that usually objects should have one-to-many relationship.
A "rare many-to-many" relationship is still a M:M relationship, and should be modeled correctly. This involves creating an intermediate or association table linking the two tables together. Your queries will be slightly more complex but only involves an additional join. But you'll have the satisfaction and admiration of your peers that you modeled your tables correctly :)
Randy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With