Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat tool generates diagrams from SQL Server hierarchical data?
    primarykey
    data
    text
    <p>Is there a tool that works with SQL Server to generate tree-like diagrams from a hierachical data model?</p> <p>I am working with a large geographical hierarchy, and would like to visualize it.</p> <p>Here is an example.</p> <p>I have a NodeHierarchy table that stores a hierarchical relationship among nodes. Each row in the table represents a node. Each node but one has a parent node. The node that has no parent is the root if the hierarchy.</p> <p>Here is how I create my table:</p> <pre><code>CREATE DATABASE HierarchyTest; GO USE HierarchyTest; GO CREATE TABLE NodeHierarchy ( PK_NodeID INT NOT NULL CONSTRAINT PK_NodeHierarchy PRIMARY KEY, FK_ParentNodeID INT NULL CONSTRAINT FK_NodeHierarchy_NodeHierarchy FOREIGN KEY REFERENCES NodeHierarchy(PK_NodeID), Name NVARCHAR(255) NOT NULL ); </code></pre> <p>I have an example hierachy of Scottish cities and venues. Scotland is the root of the hierachy. The descendants of Scotland are cities and venues. In this hiearchy, a parent 'contains' a child, so we say that e.g. "The Barrowlands is in Glasgow, and Glasgow is in Scotland".</p> <p>This statement populates the NodeHierachy table with eample data:</p> <pre><code>INSERT INTO NodeHierarchy(PK_NodeID, FK_ParentNodeID, Name) VALUES (1, NULL, N'Scotland'), (2, 1, N'Glasgow'), (3, 1, N'Edinburgh'), (4, 1, N'St Andrews'), (5, 2, N'The Barrowlands'), (6, 2, N'The Cathouse'), (7, 2, N'Carling Academy'), (8, 2, N'SECC'), (9, 2, N'King Tut''s Wah-Wah Hut'), (10, 3, N'Henry''s Cellar Bar'), (11, 3, N'The Bongo Club'), (12, 3, N'Sneaky Pete''s'), (13, 3, N'The Picture House'), (14, 3, N'Potterrow'), (15, 4, N'Aikman''s'), (16, 4, N'The Union'), (17, 4, N'Castle Sands'); </code></pre> <p>Output of <code>SELECT * FROM NodeHierarchy;</code>:</p> <pre><code>PK_NodeID FK_ParentNodeID Name ----------- --------------- --------------------------------- 1 NULL Scotland 2 1 Glasgow 3 1 Edinburgh 4 1 St Andrews 5 2 The Barrowlands 6 2 The Cathouse 7 2 Carling Academy 8 2 SECC 9 2 King Tut's Wah-Wah Hut 10 3 Henry's Cellar Bar 11 3 The Bongo Club 12 3 Sneaky Pete's 13 3 The Picture House 14 3 Potterrow 15 4 Aikman's 16 4 The Union 17 4 Castle Sands (17 row(s) affected) </code></pre> <p>In <a href="http://freemind.sourceforge.net/wiki/index.php/Main_Page" rel="nofollow noreferrer">Freemind</a> I drew this equivalent diagram: <img src="https://i.stack.imgur.com/a8MXT.png" alt="mindmap of Scottish venues"></p> <p>What tool can do this for me with a minimum of manual effort?</p> <hr> <p><strong>EDIT:</strong> Originally I said that I wanted to visualize "all or part" of the hierarchy. The solution posted here visualizes the entire hierarchy unconditionally. This is fine for the small example hierarchy, but for a larger one, it may be more useful to visualize only part of it.</p> <p>Because I didn't specify what I meant by "part", I have removed this from the question. I have asked about partial visualization in <a href="https://stackoverflow.com/questions/7462420/how-to-visualize-only-the-descendants-ancestors-and-self-of-a-node-in-a-hierarc">another question</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload