title: SQL Hierarchy Visualization
body: <p>I have a following problem:</p>
  <ul>
  <li>There exists an entity called Branch.</li>
  <li>A branch may belong to another branch or may be a standalone branch.</li>
  <li>A parent branch may belong to another branch or may be the highest level branch.</li>
  <li>There may be a UP TO 4-5 levels of hierarchy.</li>
  <li>There are no loop hierarchies (that we know of as of right now).</li>
  </ul>
  <p>I am wanting to somehow export the data from SQL and visualize into some sort of tree looking diagram. Any ideas are highly appreciated.</p>
  <p>Here is a snapshot of my data model. Note that when DivisonParentBranch = RegionParentBranch = Branch, this implies that branch is standalone.</p>
  <pre><code>DivisionParentBranch RegionParentBranch Branch
                   150                401    401
                   150                401    402
                   150                401    403
                   150                401    404
                   273                248    248
                   273                248    277
                   273                248    278
                   273                273    273
                   273                273    286
                   273                273    408
                   273                273    809
                   356                356    356
                   356                356    358
                   356                356    363
                   356                356    405
                   356                356    773
                   356                357    357
                   356                361    361
                   356                361    364
                   739                511    511
                   739                511    513
                   739                511    514
                   739                511    515
                   739                511    517
                   739                511    519
                   739                511    520
                   739                511    779
  </code></pre>
  <p><a href="https://i.stack.imgur.com/snIcA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/snIcA.png" alt="enter image description here" /></a></p>
  <h1>UPDATE:</h1>
  <p>Expected Result is to visualize these branch hierarchies. Something along the lines of the below image. We have around 500+ branches so need to automate this somehow.
  <a href="https://i.stack.imgur.com/JxsHX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JxsHX.png" alt="enter image description here" /></a></p>