title: Representing hierarchical relationships with "multiple inheritance" in a relational database
body: <p>I'm working on a python program that allows the user to categorise files by attaching 'tags' to them. These tags can stand in hierarchical relationships to one another. For example, the 'cat' tag can be categorized as a "descendant" of the 'mammal' tag. As a consequence, once a file is tagged as 'dog', it can be accessed via the 'mammal' tag as well.</p>
  
  <p>These tags and their relationships to each other and to files will obviously need to be stored in a database, and I'm most familiar with relational databases.</p>
  
  <p>I very much like the <a href="http://www.sitepoint.com/hierarchical-data-database-2/" rel="nofollow">Modified Pre-order Tree Traversal</a> method for storing trees in a relational database because it removes the need for recursion and requires fewer database queries.</p>
  
  <p>However, I also want to facilitate tags with multiple parents. For example, 'dog' could be a child of 'mammal' and also of 'four-legged-thing' where not all four legged things are mammals or even animals (e.g. tables), and the 'mammal' and 'four-legged-thing' tags have no "common ancestor".</p>
  
  <p>Does anyone know of a method of representing such relationships in a database while maintaining some of the advantages of the MPTT method?</p>
  
  <p>Thanks for any help.</p>