There are three standard practices: 1. The earliest practice: the node id contains the complete path (Great Grandfather id-ye id-parent id-Ben id) the Financial Accounting subject number is basically used now. 2. Recursive practice: parent id and local id (the early and complete relationship can be obtained through recursion) currently, the common advantage is that it is intuitive and simple. The disadvantage of adding or deleting a tree is that it is easy to generate a tree.
There are three standard practices: 1. The earliest practice: the node id contains the complete path (Great Grandfather id-ye id-parent id-Ben id) the Financial Accounting subject number is basically used now. 2. Recursive practice: parent id and local id (the early and complete relationship can be obtained through recursion) currently, the common advantage is that it is intuitive and simple. The disadvantage of adding or deleting a tree is that it is easy to generate a tree.
There are three standard practices:
1. earliest practice: the node id contains the complete path (Great Grandfather id-ye id-parent id-Ben id)
This is what the financial account number does.
It is rarely used now.
2. recursive method: the parent id and the local id (the early and complete link can be obtained after recursion)
It is common
The advantage is that it is intuitive and easy to add and delete
The disadvantage is that tree generation requires recursion.
3. Direct storage method: local id, root id, number of layers, serial number in the root (subtree)
I don't seem to see anyone using this. I used it in my own tree-shaped Forum offline reader.
The advantage is that recursion is avoided and tree records are generated efficiently and conveniently.
The disadvantage is to add or delete nodes and update the node records of the half subtree.