Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Nested Sets vs. Nested Intervals

Re: Nested Sets vs. Nested Intervals

From: -CELKO- <jcelko212_at_earthlink.net>
Date: 9 Nov 2005 17:19:10 -0800
Message-ID: <1131585550.727621.170830@f14g2000cwb.googlegroups.com>


>> Nested sets is often quoted as a solution for static hierarchies. It is rarely mentioned that one can't query ancestors path efficiently. <<

An employee and all their Supervisors, no matter how deep the organizational tree, with a column for sorting the path from root to a node:

SELECT O2.emp, (O2.rgt- O2.lft) AS path_order

   FROM OrgChart AS O1, OrgChart AS O2
  WHERE O1.lft BETWEEN O2.lft AND O2.rgt     AND O1.emp = @myemployee
 ORDER BY path_order DESC; Received on Wed Nov 09 2005 - 19:19:10 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US