I've got a tree that is described by 2 different tables. One table is
for the nodes, and another is for the relationships. The relationship
table simply has a child_node_id and a parent_node_id. I'd like to
find a way to find the root relations, something like: Relation.roots
the roots are relationships that have child_node relationships
pointing to them (by the child_node relationship parent_node_id's) but
don't have any other relationships pointing to them as if they were
child nodes. In other words, I want to find all relations that have
child nodes, but no parent nodes. This seems difficult because every
relation has a child_node_id and a parent_node_id.
It seems to me that I'd have to do some kind of nested select or a
tricky join on the same table. Anyone want to take a shot at this?
I've copied in my fixtures below. The root relations in this case
would be the mom and dad relations.
Here is an example of my node fixture:
description: grandchild of mom and dad