I have a list, where each list entry is tagged with multiple tags. Each tag can also have child tags. Every entry in the list can have more than one tags.
For example, a list entry that talks about cars can have tags called “cars”, “vehicles”, “ferrari”.
I should be able to view a hierarchy of tags, like shown below. Also, there should be no limit to number of tags per entry, and also how deep the tags can go.
How do I store this data? I am open to using any type of DBMS.

The naive approach would be a parent / child solution, but it’s very difficult to write efficient queries with this data model.
Managing Hierarchical Data in MySQL is a pretty good article about hierarchical data structures. I suppose most of it can be applied to other database systems, too.