I have an issue with structuring som data. The idea is to have some sort of menu card, where you can build your own menu. The different products are categorized into groups, and in some of the groups you can choose between eg. three different predefined 'submenus' - so you would have nested menus. As it is now, they are simply stored as nested trees in the database. The problem is, that we have a lot of different views, where the this structure is somehow irrelevant (eg. (complicated) list views with chosen products). This is pretty impractical to iterate over all these substructures and make them into a list, and it feels wrong to store the data in this way, just to make the view.
My suggestion is to simply have the products in a list, with an attribute indicating which menu they belong to. My problem is, that I don't know any smart way to store the structure of the menus belong to the attribute, and still making it possible to reconstruct the menu as it looked when they created it (ie. with all the submenus they did not choose) - even though the template menu has changed. Please note that that the structure cannot be hardcoded in any way, since the template is dynamically constructed by "menu designers".