Hi,

i would like to know if there are any guidelines on how to store tree data, that will be used for rendering a tree panel, in the database. I'm especialy interested in the topic from the performance aspect. So how to efficiently build a tree that will be rendered in a tree panel.

I currently store the tree in a table where each node has the information about its parent and the absolute path of the node in the tree (all parent node ids like 1,4,24 if the nodes first parent is the node with the id 24, the second is 4 and the first 1). Then I fetch the data and sort it by path. after that i recursively build the tree by finding the current nodes children.

What I would like is to use the algorithm that builds the tree by references: http://tech.vg.no/2011/10/31/buildin...ng-references/ The problem I found is, that the tree sent to the client then looks something like this:
Code:
[
 1:{id: 1, children:[ 
     8: { id: 8}
     4: {id: 4}
     ]}
]
I think that the tree requests the indexes of nodes to be ordered and start with 0 and end with n (number of elements)

Thank you!
Primoz