I have a page where you drag and reorder items, their order is stored numerically in a db.
In the end I will have multiple categories where you can reorder objects and an object can appear in multiple categories.
I need to store multi order numbers for each object.
Would it be more efficient to:
a) Have a table where each row is: category id, item id & position array
OR
b) Have a table where each row is: category id, item id, position
So choice "a" is less rows but contains an array and choice "b" is simpler data and more rows.
Any help would be appreciated, thanks!
Array or Individual Rows
Moderator: General Moderators
Re: Array or Individual Rows
If you want your objects to appear in more than one category I would suggest using a relational db structure.
Wiki
For example:
Category
ID | NAME
Item
ID | NAME
Category_Item
category_id | item_id
Wiki
For example:
Category
ID | NAME
Item
ID | NAME
Category_Item
category_id | item_id
Re: Array or Individual Rows
I'm already set up that way.
Tables are (for argument sake):
- items
- categories
- items_categories
I'm looking to add a forth table, something like items_categories_order and questioning if the each order should be a row or array.
Tables are (for argument sake):
- items
- categories
- items_categories
I'm looking to add a forth table, something like items_categories_order and questioning if the each order should be a row or array.
Re: Array or Individual Rows
Why not add the ordering column in items_categories if you want sepparate order per category?
Re: Array or Individual Rows
Why didn't I see that! Thanks.