12 Replies
Approach 3: use approach 2 but load the data from a file
What does that mean?
The things I'm trying to order are defined in code, and are not user objects / rows
Do they have to be defined in code?
Or are they just data
I guess you could define them in a csv file or something
but that still begs the question would the item rows have an order column or would the group table have a column for List of item ids
which resource should control the order
I'd say it depends: are the items the focus, or are the groups?
If the items are the focus, I'd say give them the group ID, order, and so on
Akin to, say, a blogpost having tags and a category
The second approach would be useful if an item can belong to multiple groups
Since you can have the same reference in multiple of them
I see, how about the problem of re-ordering in approach one?
You would have to edit something anyway
In the first example, you change a
5
to a 6
If I wanted to move the Last Item to the front, I would have to increment all items order?
In the second, you would have to cut-and-paste blocks of code between groups
Would you ever use the second approach in a one to many relationship?
Hard to say, tbh. I'd just store those items in a proper database and load them into either structure depending on my needs
Gotcha, thanks! 🙂