This is a bit ugly but allows 2.x style category tree. So a tag+parent+type combination is unique. This means you can have identical tags under different parents, but not under the same one. I think this seems sane.