[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to create a hierarchical data tree from a table

Posted on 2013-02-07
2
Medium Priority
?
560 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:
Meir Rivkin earned 2000 total points
ID: 38863710
create json representation of your hierarchical tree.
here's an example:
populating-jquery-tree-with-json-data
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

825 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