I already have a structured database with different tables like: Sports, Categories, Activities, Localities- all of them populated with items by the Admin

Sport items: Football, Tennis ...

Category items: Team Sports, Water Sports, Air ...

Activity items: Training, Match, Seminar ...

Locality items: Sports Hall, Stadium, Tennis Court

All of the items in the tables above are (or I want them to be) 'tag candidates'.

Some of the tables are associated like Categories and Sports (1:m), but not all of them. Since I can't link all of this together into one logical entity, I decided to go with tagging. I want to be able to tag content but also preserve some of the structure since I use it for navigation

I've read some implementations for tagging like the "Toxi" solution but it uses a separate Tags table. So now I wonder if I need to migrate all existing items from my existing tables that are 'tag candidates' into a single Tags table (and having a foreign key of the Tag in the corresponding table!?)

Can anyone point me to a tutorial/solution for my scenario or suggest implementation.

Thank you

有帮助吗?

解决方案

Your tags seem polymorphic, that is: your tags are of different types, you've got Sports, Categories, Activities, Locations etc.

Relational databases aren't very good at dealing with polymorphism.

You still seem to be in the reconnaissance phase so my recommendation is you read up on polymorphism in relational databases.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top