Representing Trees in PostgreSQL
Does anyone remember how Drupal handles the hierarchical comments? It maintains a "sort key" field for each comment, which consists of multiple index numbers for all levels, much like the section numbers in Wikipedia.<p>1<p>1.1<p>1.2<p>2<p>2.1<p>2.1.1<p>2.1.2<p>2.1.2.1<p>In this way, displaying comments in a tree form is trivial. Just ORDER BY the sort key. I find it brilliant for applying to such an application.