I've a simple question.
My database structure is:
id | name | left | right // no need to tell me that left, right are reserved keywords
The only data in the database:
1 | family | 1 | 2
Now, I want to add new child
to the family: mother
. So theoretically I should take the right value of the element to which I want to add the child and free-up some space after it.
UPDATE `hp_tree` SET `right`=`right`+2 WHERE `right` > 2;
UPDATE `hp_tree` SET `left`=`left`+2 WHERE `left` > 2;
And then simply insert the child mother
:
INSERT INTO `hp_tree` SET `left`=2, `right`=3, `name`='Mother';
Now, the problem is, that this way the family
(root element) right
value is not updated. Am I doing it wrong?