Member • Jul 2, 2013
Pen down these SQL queries
Suppose you have a binary tree structure represented as in attachment 1.jpg
Suppose the details of the figure in attachment are stored in a table as follows:
Parent Child
------ -----
A B
B D
B E
A C
C F
Assume that the tree has n number of nodes so the rows in the table will be having a lot of rows
Write SQL for:
1) Finding the leaf nodes.
2) Finding the child nodes of B.
3) Finding the nth child of node A.
4) For a given node, print the complete path from the ultimate parent till that node.
Please let me know in case you need any clarifications with these questions.