I have two tables in Oracle for representing various trees, the tables are: "PARTS_TREE_ENTRIES" where all the nodes are stored (including parents and children) and "PARTS_ITEMS" wich describes the relation between the nodes
In the table TREE_ITEMS the column COMPONENT_ID represents the father and COMPONENT_ITEMID its child
There are more than one tree and the nodes of all the trees are in the same table "TREE_ENTRIES" To make it easier to undestand this is a representation of a couple of trees:
And these are their entries in the tables:
As you can see in the table TREE_ITEMS the nodes that are the root of a branch have the value "A" for the COMPONENT_ID
I need help to build a query to get a list of all the nodes of the last level with its parents and its ID, the output should be similar to the following:
I've read about the clause "Connect by" but I've never used it and I dont where to start.
Thank you very much in advance!
Copyright Notice:Content Author:「Alfredo Garcia」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/36410849/build-a-tree-from-oracle-tables