On Mon, 10 Jun 2019 at 20:21, sergio ruiz <sergio....@gmail.com> wrote:
> I am currently putting together a Seaside website for my radio show. I am > trying to figure out how to model the "has and belongs to many" > relationships. > > Each episode can have many tracks, each of these tracks can belong to > several episodes. > I want to be able to present a listing of which episodes each track > appears in, and a listing of tracks for each episode. > > The approach I have seen on this is to create an intermediary object and > store a set of ids on this, but this seems a little clunky, and it seems > like there would be a clean way to do this. > This is how you'd model many-to-many relationships in relational databases. https://dzone.com/articles/how-to-handle-a-many-to-many-relationship-in-datab If that is where your data is stored, you may be forced to this. If you are keeping your design purely in the object-oriented domain, you might try Mutual Friends... https://pdfs.semanticscholar.org/348f/e4ecff3c23f3709bb88e7e60379905a3b930.pdf although I've not enough experience with it to know if its the best way. Or you might try relation slots. Check out SlotExampleMovieAndPersonTest. Some background reading... https://rmod.inria.fr/archives/papers/Verw11a-OOSPLA11-FlexibleObjectLayouts.pdf which I'd guess is still useful even if I read somewhere it was a bit out of date. cheers -ben