See RDF/OWL, what's right with it, what's wrong with it, and start from there. Don't reinvent the wheel, there are very fast and scalable algorithms to handle most of the things you want to do with a database of categories, even if half of them were omitted from standards and most of the discussion of "the semantic web".
One interesting bit of math from OWL is a proof that you can aggregate queries over multiple SQL databases in a way that is smart about ontologies.
One interesting bit of math from OWL is a proof that you can aggregate queries over multiple SQL databases in a way that is smart about ontologies.