Solved

how to create a hierarchical data tree from a table

Posted on 2013-02-07
2
531 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
ID: 38863689
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
ID: 38863710
create json representation of your hierarchical tree.
here's an example:
populating-jquery-tree-with-json-data
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.‚Äč
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

861 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