Hi Joseph,
You can use a recursive query. This SQL is for SQL Server. You can customise the columns you get back from the query to display the path or do other functions on the data. This query retrieves all the compound relationships in the DB, displays the child and parent component ID, shows the depth of the relationship where 0 is the first one, shows the path using the relationship object ids.
WITH cte_org AS (
SELECT
object_id,
parent_component_id,
child_component_id,
cast(convert(nvarchar(36), object_id) as text) as cdpath,
0 as depth
FROM
ComponentRelation
UNION ALL
SELECT
e.object_id,
e.parent_component_id,
e.child_component_id ,
cast(concat(o.cdpath,'->', convert(nvarchar(36),e.object_id )) as text) as cdpath,
o.depth + 1
FROM
ComponentRelation e
INNER JOIN cte_org o
ON o.child_component_id = e.parent_component_id
)
SELECT * FROM cte_org order by parent_component_id, child_component_id;
------------------------------
David Alfredson
------------------------------