In my project I have two tables in a many_many relationship:
Template (id, templateName)
Item (id, itemName)
Template_Item (id, templateId, itemId)
The idea is that you create a template and assign Items to it. A ‘complete’ template is one that has a bunch of stuff attached to it. You can think of it as a tasklist where the template is the type of tasklist (Build Garage, Fix Car) and the Items are tasks on the list.
Since Items can be used on muliple Templates I setup a junction table with many to many.
The problem I’m having now is that I need to display the Items on a template in order.
My first thought was to add a sortOrder field to the junction table Template_Item.
However, a guy on another post suggested that if I do this I don’t really have a MANY_MANY relationship but rather two sets of HAS_MANY relationships, ie:
Template HAS_MANY Template_Item
Item HAS_MANY Template_Item
Template_Item BELONGS_TO Template (and Item)
How should this be modeled?