D
D
dllweb2016-12-07 14:43:21
nested set
dllweb, 2016-12-07 14:43:21

How to move categories, I suffer the 3rd day?

I really want to understand what happens, in fact, when a node moves in the nested set hierarchy structure In the picture, let's say we shift
nestedsets3.gif
the "Snr.Developer" Branch in the Customer Service.
It turns out that the shift to the left and I also want to understand the algorithm or pattern of shifts.
to the right Customer Service in Development Manager
I even drew a diagram in paint, moved it, recalculated it, tried it as it looks in the picture, but no, something always goes wrong, tell me where to get information in a more or less clear form about a very detailed explanation of Nested set
PS: The table has fields only id category_name left_key right_key

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Talalaev, 2016-12-07
@neuotq

And what exactly is not clear, like a simple model. In the classic nested sets, when permuting, you need to recalculate the entire tree (subtree). I don’t remember where I read a simple explanation myself (it was a long time ago), but here it seems to be quite clearly explained www.poiu.ru/lessons/index.php-18.htm
In short, you simply recalculate the value of left_key right_key based on new realities.
In general, the rate of new elements is relatively expensive in this model.
Therefore, there is an improved version of the nested intervals algorithm and model, here is an example from yii2 https://github.com/paulzi/yii2-nested-intervals , it's really really harder to understand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question