According to various embodiments, systems, and methods, a sorting
construct (TREE_SORT) is generated to efficiently traverse hierarchical
data structures in relational databases. A TREE_SORT construct is
generated by transforming a value that represents the sequential order of
a given node relative to its siblings (Peer_Sequence) to a left-justified
string of a given width. A TREE_SORT value for the parent of a given node
is prepended to the left of the generated substring of the transformed
Peer_Sequence value. As a result, a sorting construct of the parent node
sorts before sorting constructs of child nodes.