I want to build a WebApp where the user can create an unlimited deep tree structure JSON object. The goal is to send this hierarchical JSON to the backend and store the nested objects with the parent/child relation in a database.
Setup
- The chain can contain multiple objects
chain = [
{name: "name1",
children: []
},
{name: "name2",
children: []
}]
- Each object in the chain can contain other objects in the children array:
chain = [
{name: "name1",
children: [{name: "name1child", children: []}]
},
{name: "name2",
children: []
}]
- each object can contain multiple children's
- the children's can also contain multiple children's
Questions
Is this a good solution for modelling the hierarchy in the frontend? I feel like it gets complex when adding/updating/deleting a deep nested object in the chain. In addition i can only search objects by name in the frontend. Is there a better way than that?
How can these objects be stored in a Database without loosing the hierarchy? Is a relational database suited? What about NoSQL or even GraphDb (I have no experience with Graphs).
I know this question is relatively broad. Is this an appropriate schema for handling this nested structure?
Thanks for your help :)