arangodb
arangodb copied to clipboard
Store trees in ArangoDB
Which is the best practice for storing trees in ArangoDB? I need to use graph, edges & etc? But where to find examples of basic tree operations like read, path, insert, delete, move & etc?
Or I need to use Nested Sets & etc like when storing trees in MySQL?
Of course it is possible to store all tree in one row as JSON but it is not useful for manage tree and using keys from the tree especially if I work with big trees
P.S. sorry for my bad English((
You can do all of these things, it just depends on how you want to access and use the data.
If you want to use the graph features of ArangoDB the most sensible choice is using an edge collection to store the edges connecting the tree's vertices (which can be regular documents in document collections). This allows you to traverse the tree efficiently and use graph functions.
Thank you for your fast reply)
I don't need any special graph features for trees. I want to store nested folders with unlimited depth and inside the folders store records or keys. I don't need data structure more optimised for reads or writes. I'm looking for easy way for organise tree(INSERT/DELETE/MOVE tree nodes and of course...read all children's for selected node) I'm not familiar with graph part of ArangoDB but I really like AQL) At the moment I think that more easy way is to store tree in Nested Sets format and I will need only one AQL query for every operation with tree. I think this is not Arango way) Maybe you know a good example of simple operations like insert/delete/move with regular tree graph?
P.S. sorry for my bad English and possibly stupid questions((
I think documentation for this global use case will be awesome. Store regular website menus, that require tree structure with ordering (important).
Something like (multiple root)
- Menu Position 1
- Home
- Products
- New Products
- Most sales
- Categories
- Computers
- Tools
- Menu Position 2
- Home
- About Us
Is there anyone who can help with this?
Is there anyone who can help with this?
@SultanNasyrovDeveloper What kind of help do you need?
I can try to find my old sources to work with Nested sets using arangodb transactions
Is there anyone who can help with this?
@SultanNasyrovDeveloper What kind of help do you need?
I can try to find my old sources to work with Nested sets using arangodb transactions
First of all i need to understand why would you use this pattern to store tree in graph database? I though about just parent to child edge.
First of all i need to understand why would you use this pattern to store tree in graph database? I though about just parent to child edge.
Just because I used to use it in relational databases before. And this pattern allows you to make very fast selections without recursion. Maybe in ArangoDB it's more fast and easy to use an edge collection and graph traverse but I didn't try it