| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Storing hierarchical information?
I currently have a database which stores a hierarchical tree of documents which make up a policy manual for work. The hierarchy is handled really simply - each document has a parent attribute, if the parent attribute is null then that document is a "root" document. This works rather well in some ways, but sucks incredibly in other ways. Documents are identified by a docid, startdate, and enddate, which allows me to keep track of changes very easily. Instead of making a change by updating, I make a change by updating the current revision and setting enddate = now(), then adding a new document with startdate = now(). The interface is entirely web based, the database is MySQL.
For example, one of the ways it sucks is that each document must have a unique document ID. Ideally, the IDs should be descriptive, but we have a lot of repeating between sections. So the DE and DA sections of the manual might both have a policy on Documentation, and they are nearly identical, but they need unique IDs. This isn't too bad, but it might get hairy since we plan to add a ton of documents in the near future.
Also, we plan on having multiple roots in the near future and we'd like to have them seperate. So when you're in rootA, you can't see documents belonging to rootB. Right now, this is easy to do for everything except things that apply across multiple documents, such as searching or getting a list of recent changes. Basically, I will have to find the root document by recursively reading the parent attribute until I find a null, then I will have to generate a list of all documents that eventually lead back to this parent document, then I will have to restrict the search to apply to just those documents. This is nasty and very slow, but yes, it does work.
So, what I want to ask is this: Is there any "proper" way to store hierarchical data in a database, much like operating systems store files? Is what I'm doing fine, or is there a way that could be faster?
I'd rather not just throw more hardware at this.
Here are some of the solutions I've thought of so far:
Thanks in advance for your input!
-- Dave Kimmel
criscokid_at_v-wave.com
ICQ: 5615049
Received on Mon May 07 2001 - 12:45:59 CDT
![]() |
![]() |