title: Adjacency List Model vs Nested Set Model for MySQL hierarchical data?
body: <p>There are <a href="http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/">two ways to work with hierarchy data in MySQL</a>:</p>
  
  <ol>
  <li>Adjacency List Model</li>
  <li>Nested Set Model</li>
  </ol>
  
  <p>A major problem of the <strong>Adjacency List Model</strong> is that we need to run one query for each node to get the path of the hierarchy. </p>
  
  <p>In the <strong>Nested Set Model</strong> this problem does not exist, but for each added node is necessary to give a MySQL UPDATE on all others <em>left</em> and <em>right</em> value.</p>
  
  <p>My hierarchical data is not static data, such as product categories of e-commerce. Are constant registration of users in hierarchical sequence.</p>
  
  <p>In my application, while there are many constants users registration, I also need to get the hierarchical path until reach the first node in the hierarchy.</p>
  
  <p>Analyzing my situation, which of the two alternatives would be best for my application?</p>