I've following tasks. t1, t2, t3, t4, t5, and t6. There can be any number of such tasks. I've taken 6 tasks just for the example.
Each task may depend on some parent tasks, a task cannot have more than 1 parent task. Conversely, each task may have one or more dependent tasks.
Let's consider following example:
parent-task child-task
t5 t4
t6 t5
t1 t6
t2 t3
t4 t2
Children task hierarchy of t5: t4 <-- t2 <-- t3
Children task hierarchy of t6: t5 <-- t4 <-- t2 <-- t3
Children task hierarchy of t1: t6 <-- t5 <-- t4 <-- t2 <-- t3
Children task hierarchy of t2: t3
Children task hierarchy of t4: t2 <-- t3
Children task hierarchy of t3: empty set
parent task hierarchy of t4: t5 --> t6 --> t1
parent task hierarchy of t5: t6 --> t1
parent task hierarchy of t6: t1
parent task hierarchy of t1: empty set
parent task hierarchy of t3: t2 --> t4 --> t5 --> t6 --> t1
parent task hierarchy of t2: t4 --> t5 --> t6 --> t1
I'm not being able to figure out query that can give me hierarchy of parent and children tasks of each task. Stored procedures aren't allowed. So, I can't write a stored procedure.