473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

tree structure select problem

ven
hello i have a table with four fields : name_id, name, tree_id, level with
these data:

1 name1 001 1
2 name2 002 1
3 name3 003 1
4 name4 001001 2
5 name5 001002 2
6 name6 001003 2
7 name7 001001001 3

tree:

1-
- 4
-7
-5
-6
2-
3-

and procedure which add nodes to tree looks tree.add(idparent,idchild,name)

how to write select which returns idparent,idchild and name then i can add
nodes in loop reading datareader ?
Nov 6 '05 #1
4 2167
ven
sorrry i forgot one think the select should return somethin like :

root 1 name1
root 2 name2
root 3 name3
4 1 name4
5 1 name5
6 1 name6
7 4 name7
Użytkownik "ven" <ve*****@poczta.onet.pl> napisał w wiadomo¶ci
news:dk**********@news.onet.pl...
hello i have a table with four fields : name_id, name, tree_id, level with
these data:

1 name1 001 1
2 name2 002 1
3 name3 003 1
4 name4 001001 2
5 name5 001002 2
6 name6 001003 2
7 name7 001001001 3

tree:

1-
- 4
-7
-5
-6
2-
3-

and procedure which add nodes to tree looks
tree.add(idparent,idchild,name)

how to write select which returns idparent,idchild and name then i can add
nodes in loop reading datareader ?

Nov 6 '05 #2
ven (ve*****@poczta.onet.pl) writes:
hello i have a table with four fields : name_id, name, tree_id, level with
these data:

1 name1 001 1
2 name2 002 1
3 name3 003 1
4 name4 001001 2
5 name5 001002 2
6 name6 001003 2
7 name7 001001001 3

tree:

1-
- 4
-7
-5
-6
2-
3-

and procedure which add nodes to tree looks
tree.add(idparent,idchild,name)

how to write select which returns idparent,idchild and name


Since I answered a similar query earlier this week, I'm lazy and refer
you to that thread:
http://groups.google.com/group/comp....9fcc60b9ca2ed1

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Nov 6 '05 #3
You might want to look at the Nested Sets model for trees instead.

Nov 7 '05 #4
The nested set method you will see is:-

1) Difficult to maintain
2) Does not scale nor perform well out of the lab and in the real
world.

A better method is that developed by Itzik Ben Gan, information here:
http://www.windowsitpro.com/Articles...layTab=Article

--
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"ven" <ve*****@poczta.onet.pl> wrote in message
news:dk**********@news.onet.pl...
hello i have a table with four fields : name_id, name, tree_id, level with
these data:

1 name1 001 1
2 name2 002 1
3 name3 003 1
4 name4 001001 2
5 name5 001002 2
6 name6 001003 2
7 name7 001001001 3

tree:

1-
- 4
-7
-5
-6
2-
3-

and procedure which add nodes to tree looks
tree.add(idparent,idchild,name)

how to write select which returns idparent,idchild and name then i can add
nodes in loop reading datareader ?

Nov 9 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: imani_technology_spam | last post by:
We need to present hierarchical data on a web page, the same way the tree view shows files in Windows Explorer. Here's the catch: that tree view needs to be bound to a SQL Server database. How...
2
by: ragha | last post by:
Dear friends I am emulating thr tree structure mentioned in the article http://www.15seconds.com/issue/010921.htm I have succesfully created the folder structure for level 2 I need this...
4
by: Jean-Christophe Michel | last post by:
Hi, In a complex merging of two (non ordered) xml files i need to keep track of the elements of the second tree that were already merged with first tree, to copy only unused elements at the end....
4
by: Robin Tucker | last post by:
Hi, I'm currently implementing a database with a tree structure in a table. The nodes in the tree are stored as records with a column called "Parent". The root of the tree has a "NULL" parent....
19
by: Christian Fowler | last post by:
I have a VERY LARGE pile of geographic data that I am importing into a database (db of choice is postgres, though may hop to oracle if necessary). The data is strictly hierarchical - each node has...
4
by: Stephan Tobies | last post by:
Hi everyone, I am looking for a good data structure that could be used to represent families of trees with shared sub-trees and copy-on-write semantics. On a very abstract level, I would like...
4
by: Ken | last post by:
I have a binary tree in VB NET and insertions seem to be slow. The program receives data from one source and inserts it into the tree. The program receives data from another source and...
5
by: hankypan1 | last post by:
Hi All, I need a tree data structure for my application. It is the non -cyclic simple tree where i can have any number of children node and each child can recursively become a sub tree like a...
8
by: =?ISO-8859-1?Q?m=E9choui?= | last post by:
Problem: - You have tree structure (XML-like) that you don't want to create 100% in memory, because it just takes too long (for instance, you need a http request to request the information from...
9
by: smarttechie | last post by:
Hii all please help its urgent i have developed an application in xsl. what i want to do is i m searching the xml file based on a search.and based on that search im creating one tree like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.