I have articles on my website and I would like to add tags that will describe each article, but I am having problems with the mysql table design for tags. I have two ideas:
- in each article there will be field "tags", and tags will be in the format: "tag1, tag2, tag3"
- create another table with tags with fields: tag_name, article_id
So, when I want tags for an article with ID 1, I would run
SELECT ... FROM tags WHERE `article_id`=1;
But I would also like to know the 3 most similar articles comparing tags, so if I have an article with tags "php, mysql, erlang" and 5 articles with tags: "php, mysql", "erlang", ruby ββ"," php erlang "," mysql, erlang, javascript ", I would choose 1., 3. and 4. since these 3 have the same tags with the main article.
Also another question, what is the best way to get the 10 "most used tags"?
mysql database-design tag-cloud
mfolnovich
source share