title: How do I store URL fragments in a database?
body: <p>How are URLs (fragments) stored in a relational database?</p>
  <p>In the following URL fragment:</p>
  <pre><code> ~/house/room/table
  </code></pre>
  <p>it lists all the information on a table, and perhaps some information about the table.</p>
  <p>This fragment:</p>
  <pre><code>~/house
  </code></pre>
  <p>outputs: <code>Street 13</code> and <code>Room, Garage, Garden</code></p>
  <pre><code>~/house/room
  </code></pre>
  <p>outputs: <code>My room</code> and <code>Chair, Table, Window</code></p>
  <p>What does the Database schema looks like? What if I rename <code>house</code> to <code>flat</code>?</p>
  <h3>Possible solution</h3>
  <p>I was thinking that I could create a hash for the URL and store it along with <code>parentID</code> and information. If I rename some upper-level segment I would then need to update all the rows which contain the given segment.</p>
  <p>Then I thought would store each segment along with information and its level:</p>
  <pre><code>SELECT FROM items WHERE key=house AND level=1 AND key=room AND level=2
  </code></pre>
  <p>How do I solve this problem if the URL can be arbitrarily deep?</p>