Re: internal struct for displayed outline?

From: Steve Long <nospam_at_hotmail.com>
Date: Sat, 30 Sep 2000 16:23:03 -0400
Message-ID: <8r5hsk$rmd$1_at_bob.news.rcn.net>


since you require traversal in both directions, i suggest you need a different structure. the connect by clause in SQL provides the basic solution.

NodeID ParentID Item

001            null            FolderA
002            001            AFirstItem
003            001            ASecondItem
004            002            SubItem1ofAFirstItem
005            002            SubItem2ofAFirstItem
006            003            SubItem1ofASecondItem
007            null            FolderB

etc...

You may identify root nodes by checking where parentID is null. You may now traverse either direction.

  • Find all root nodes (top level folders) [ level 1 ] SELECT item "Folder" FROM tree WHERE parentID is null;
  • You may also use Oracle's pseudo column LEVEL
  • Find all nodes immediately below root nodes [ level 2 ] SELECT item "SubFolder" FROM tree START WITH (select nodeID from tree where parentID is NULL) CONNECT BY PRIOR nodeID = parentID;

"Cannon Fodder" <technews_at_invalid.sorry> wrote in message news:Pine.LNX.4.04.10009291831130.10946-100000_at_snoopy...
>
> Hi,
>
> Let's say I developed a front-end application in ANSI C, for
> instance to display something like the following:
>
> FOLDER A:
> Almanac
> Annual Reports:
> 1986
> 1997
> 2000
> FOLDER B:
> Battle of Britain Computer Game Manual
> Bi-weekly Newsletters:
> Week 1:
> "Community develops forum"
> "Local Geneology KIOSK reopens"
> <etc>
> <etc>
> <etc>
>
> The main purpose of this application would be to search the
> hiearchical list and then backtrace the item back up and to the
> left to determine where to physically dig in for a particular
> item. I might add extra internal information (fields) such as
> IN/OUT at a later date. Periodically, a query would be made to
> list the 'OUTs' and etc.
>
> My question is how would one structure the raw core of data
> itself? Something like this below or something else?
>
> 001,001, FOLDER A
> 002,002, Almanac
> 003,002, Annual Reports:
> 004,003, 1986
> 005,003, 1997
> 006,003, 2000
> 007,001, FOLDER B:
> 008,002, Battle of Britain Computer Game Manual
> 009,002, Bi-weekly Newsletters:
> 010,003, Week 1:
> 011,004, "Community develops forum"
> 012,004, "Local Geneology KIOSK reopens"
>
> Please post replies back to the NG, or they'll bounce.
>
Received on Sat Sep 30 2000 - 22:23:03 CEST

Original text of this message