title: Materialized path tree structure with support for duplicate path ids in MongoDB?
body: <p>In the guide for <a href="http://docs.mongodb.org/manual/tutorial/model-tree-structures-with-materialized-paths/" rel="nofollow">materialized path tree structures</a> at mongodb docs they show a simple example of how to structure data to support simple querying:</p>
  
  <pre><code>db.categories.insert( { _id: "Books", path: null } )
  db.categories.insert( { _id: "Programming", path: ",Books," } )
  db.categories.insert( { _id: "Databases", path: ",Books,Programming," } )
  db.categories.insert( { _id: "Languages", path: ",Books,Programming," } )
  db.categories.insert( { _id: "MongoDB", path: ",Books,Programming,Databases," } )
  db.categories.insert( { _id: "dbm", path: ",Books,Programming,Databases," } )
  </code></pre>
  
  <p>This works fine as long as <code>_id</code> is unique for each item. In our case, we are designing a course structure, which has to support SEO:able URLs such as <code>/course-a/lesson-1/introduction</code>. The data design must support duplicates (e.g. multiple courses can have a lesson called "introduction"):</p>
  
  <ul>
  <li>Course A
  <ul>
  <li>Introduction (lesson)
  <ul>
  <li>Part 1 (lesson)</li>
  <li>Part 2 (lesson)</li>
  </ul></li>
  <li>Background (lesson)</li>
  <li>... (lesson)</li>
  </ul></li>
  <li>Course B
  <ul>
  <li>Introduction (lesson)</li>
  <li>Why this works (lesson)</li>
  <li>... (lesson)</li>
  </ul></li>
  </ul>
  
  <p>Our current solution is to have the lessons created using the materialized path design. This is when we realized it won't work with duplicate lesson ids. But before throwing it all away, I'd like to ask for your advice.</p>
  
  <p>Is there any way to design this to support our problem using materialized paths?</p>