I'm trying to write a hierarchical query on Oracle that involves two tables:
GeoNodes
Name, uuid, lat, lon
GeoParents
parent_uuid, child_uuid
Example data:
GeoNodes
Name UUID lat lon
test1 123 0 0
test2 124 0 0
test3 125 0 0
test4 126 0 0
GeoParents
parent_uuid child_uuid
123 124
123 125
124 126
In this example, I have:
- test1 parent of test2 and test3
- test2 parent of test4
There is no null values in geoparents table. On geoparents there are two FK (one for child and one for parent) on uuid column of geonodes that maintains data integrity between the two tables.
As you can see the link between parent and child stay on an external table. To give more complexity to all, some nodes have more than one parent.
Sadly I don't understand where to put the join in the query to make it works properly. I've searched for examples but all of them have the parent column in the data table.
This is the only query that extracts some congruent data, but unfortunately is not able to obtain roots records:
select Lpad(soc || '_' || name,Length(soc || '_' || name) + LEVEL * 3 - 3,'-')
from geonodes g, geoparents p
where g.uuid = p.child_uuid
start with name = 'myTest'
connect by prior g.uuid = p.PARENT_UUID
order siblings by name;
Thanks in advance for your help.