Representing hierarchical relationships with "multiple inheritance" in a relational database
===

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.

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.

I very much like the [Modified Pre-order Tree Traversal][1] method for storing trees in a relational database because it removes the need for recursion and requires fewer database queries.

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".

Does anyone know of a method of representing such relationships in a database while maintaining some of the advantages of the MPTT method?

Thanks for any help.

  [1]: http://www.sitepoint.com/hierarchical-data-database-2/