Arangodb: Store trees in ArangoDB

Created on 26 Feb 2017  路  3Comments  路  Source: arangodb/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((

1 Question Community Help Wanted

All 3 comments

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
Was this page helpful?
0 / 5 - 0 ratings