Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tree editing by multiple users simultaneously?

I have a tree like hierarchical category which I need to save in a DB. I used MPTT (nested sets) to save this data.

The problem is that this category needs to be editable by multiple users, sometimes simultaneously.

How to preserve the integrity of the structure, without putting too much constraints on the users?

Given the nature of MPTT that when changing an element in the structure it affects other elements too (changing of the left / right values).

For ex. User A deletes Node1 and User B adds Leaf1 under Node1. This should give an error to User B that Node1 does not exists anymore, but I believe it would just create confusion for User B...

Are there any practical solutions for this problem?

like image 249
feketegy Avatar asked Dec 07 '25 01:12

feketegy


1 Answers

What you are looking for is optimistic concurrency. It means, you allow the user to begin editing the record but before you apply the changes, you check if the record is in the same state while it was when user started editing.

Other scenario is to lock all the records that might get affected by editing but it will restrict the user from making any changes.

like image 170
Murtuza Kabul Avatar answered Dec 08 '25 13:12

Murtuza Kabul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!