Solved

how to create a hierarchical data tree from a table

Posted on 2013-02-07
2
521 Views
Last Modified: 2013-02-15
I have a table which has related terms. By related terms I mean a term can have a broader term and a narrower term. See attached image for more clarification. I have a table called Relation in my database. The table has fields like Id, maintermid, relatedtermid, relationshiptypeid(say 1 for BT, 2 for NT). I run recursive queries to find all the narrower terms for a given term and similarly run recursive queries to find broader terms. My requirement is now to create a web service and send a hierarchical tree as in the attached image. I know how to develop a service but wondering how can I organize my data as a tree to send it via web service.
hireachy.png
0
Comment
Question by:mmalik15
2 Comments
 
LVL 17

Expert Comment

by:Barry Cunney
Comment Utility
USE FOR XML with a SELECT to output XML and send the XML to the web service

http://www.simple-talk.com/sql/learn-sql-server/using-the-for-xml-clause-to-return-query-results-as-xml/
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
Comment Utility
create json representation of your hierarchical tree.
here's an example:
populating-jquery-tree-with-json-data
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now