I must decided how to implement categorized structure and I wanted to based it on SQL.
I thought nested sets implementation would be good because it is quite easy. To add a node, delete node, retrive parents, children or even generate a whole tree is trivial. I additionaly store in db depth and parent id to the node to speed some selects and avoid spare calculations.
However, when I tried to order nodes on the same level I fount it quite difficult.
In short, I have to rebuilt the tree.
Here is an example:
If I`d like t o have x1 before x0 I have to calculate the size (the amount of children for each node along with it`s children and grandchildrend and, etc.) and update each node of the branch. It`s quite a lot of modifications and may cause some performance issues later.
- - x00
- - x01
- - x10
- - x11
Does order operation in nested sets always mean updating two whole branches? Is there a way to update only nodes. I really don`t like the idea of changing so many records.
Maybe I should consider other approach?
Thanks for any advices.