X Interview Question

An SQL problem: Given a list parent-child relations in a tree, which nodes are root, leaf, or inner nodes?