There are 3 standard practice types:
1, the earliest practice: The Node ID contains the full path (grandfather id-id-father id-this ID)
the ledger account number for the financial services .
It's very rarely used today.
2. Recursive procedure: Parent ID, this ID (earlier, complete relationship provides recursive ability to get)
now more common
advantages are intuitive and simple, easy to delete
the downside is that the spanning tree needs recursion .
3, Direct preservation method: This ID, root ID, number of levels, the number in the root (subtree)
I don't seem to see anyone else use it, I've used it in my own tree-shaped forum offline reader .
The advantage is that recursion is avoided. Generate tree records efficiently and easily
the downside is adding and deleting nodes. Need to update the node record of half a subtree
(previously published in: http://bbs.csdn.net/topics/390248889#post-392670699)
Standard practice for database storage hierarchy and tree structure