1

I have a tree structure like the following JSON which is created from database.

[
    {
       "id":2,
       "order":2,
       "children":[
          {
             "id":3,
             "order":1,
             "children":[

             ],
             "actions":[
                {
                   "id":1,
                   "slug":"manage",
                   "title":"manage",
                   "api":[

                   ]
                }
             ]
          },
          {
             "id":4,
             "order":2,
             "children":[

             ],
             "actions":[
                {
                   "id":2,
                   "slug":"settings",
                   "title":"settings",
                   "api":[

                   ]
                }
             ]
          }
       ],
       "actions":[
          {
             "id":190,
             "slug":"update",
             "title":"update",
             "api":[

             ]
          }
       ]
    }
 ]

This is fairly large one and the above is the JSON representation of the array. Now I need to store this tree structure somewhere and need to add/delete entries when new entries are added or removed. One method I have tried is to store this JSON into Redis and re-insert every time a new entry added or deleted. But this operation is taking a lot of time and I need to find an alternative solution for this.

What is the best method to store a tree structure and manipulate it? I already have the parent-child relation in MySQL DB.

StackUser
  • 11
  • 2
  • I am already storing the relation in database and the tree is populated from there using an application logic and which formats the data to give structure. So now, I need to manipulate this when adding/editing/deleting this tree. The duplicate question deals with how to store the tree relation, which I am already doing. I need a solution to manipulate the tree structure, without creating the tree again, which is an expensive operation. – StackUser Oct 04 '17 at 10:00

0 Answers0