Re: Does a Nested Sets tree require a single root node?

From: --CELKO-- <joe.celko_at_northface.edu>
Date: 22 Aug 2003 14:17:52 -0700
Message-ID: <a264e7ea.0308221317.30b2ff0b_at_posting.google.com>


>> It seems to me that a nested sets tree must have a single root
node. Is this true? <<

Yes; that is the mathemtical definition of a tree and a root node; it would not matter how you modeled it.

>> I am converting an Adjacency List hierarchy to Nested Sets. In a
situation where I am organizing a list of manufacturers into a tree, there is no single root manufacturer - so I would have to create an "artificial" root node called "All Manufacturers", correct? <<

That would work, or you could go with a forest -- a table of trees

 CREATE TABLE Forest
 (tree_nbr INTEGER NOT NULL,
  node CHAR(10) NOT NULL,
  lft INTEGER NOT NULL,
  rgt INTEGER NOT NULL,
  CHECK (...),
  PRIMARY KEY (tree_nbr, lft, rgt)); Received on Fri Aug 22 2003 - 23:17:52 CEST

Original text of this message