I am developing an application in android using Sqlite, I have a tree structure that I represent in db as follows:
+------+------+-------+------+
|comp_id nodeId parent| text |
|------|------|-------|------|
| 146 | 1 | -1 | Top |
| | | | |
| 146 | 2 | 1 | Ch1 |
| | | | |
| 146 | 3 | 2 | Leaf |
| | | | |
| ... | | | |
| 152 | 1 | -1 | Top |
+------+------+-------+------+
It is difficult for me to program the algorithm in a stand-alone method, as shown below, to return me all the sheets under any node.
Node
{
public Node[] getAllLeafs()
{
}
}
If there is a way to do this more easily by changing my table structure and / or using SQL, please indicate that I can do this.
source
share