Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 More Trees & Hierarchies in SQL
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

giantg
Starting Member

USA
1 Posts

Posted - 07/19/2002 :  14:16:10  Show Profile  Reply with Quote
First off Rob, I would like to say how much I like this design for a hierarchy within a relational database. I've seen other's that use many more tables (i.e. not adjacent).. I've been trying to implement this system on MS SQL Server and I have come up with an ADD procedure.. I believe MOVE and PROMOTE will be pretty trivial, but I am stuck on the DELETE procedure. The only way I can figure to even start it is to use recursion. It seems that would be the only way to make sure no nodes are truncated (i.e. no parent, not root, just floating). Or would it be better to take this approach:

If a node with children is deleted, then the children will become children of that nodes parent...

i.e.

(root) (root)
| |
/ \ -----
/ \ / | \
/ \ Delete node 2 / | \
(node 1) (node 2) ============> / | | | / | ----- / \ / | --- / \ / | - / \ / | / \ (node 1) (node 3) (node 4)
(node 3) (node 4) | | |
| | ----- ----- -----
----- ----- --- --- ---
--- --- - - -
- -
--------Key---------+
| |
----- = Terminator |
--- |
- |
--------------------+



Any insight is appreciated, Thanks.
-Greg


  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000