English

Using rational numbers to key nested sets

Databases 2008-06-20 v1

Abstract

This report details the generation and use of tree node ordering keys in a single relational database table. The keys for each node are calculated from the keys of its parent, in such a way that the sort order places every node in the tree before all of its descendants and after all siblings having a lower index. The calculation from parent keys to child keys is simple, and reversible in the sense that the keys of every ancestor of a node can be calculated from that node's keys without having to consult the database. Proofs of the above properties of the key encoding process and of its correspondence to a finite continued fraction form are provided.

Keywords

Cite

@article{arxiv.0806.3115,
  title  = {Using rational numbers to key nested sets},
  author = {Dan Hazel},
  journal= {arXiv preprint arXiv:0806.3115},
  year   = {2008}
}

Comments

18 pages

R2 v1 2026-06-21T10:52:18.885Z