Duplicate: How do you recommend implementing tags or tagging
What's a efficient, fast and elegant architecture for a tagging system (such as posts or photos). For example, you have a site like StackOverflow and each item has a couple of tags. What's the best way to keep track of these, and make them searchable. Scalability is important as well.
Have a 'tags' column per each item. So in the database for that item's row you have string with all the tags "tag1 tag2 tag3 keyword anothertag etc". Then you can allow fulltext search index on that column.
Have a tags table. Where it maps "tag":"item_id". This would make searching faster... you can search for the tag=keyowrd and get a list of all the item_ids.
Both of these seem like the obvious solutions, but for very very large data sets, seems like a pretty inefficient method. Any thoughts or other ways to implement a tagging system?