We often find some tags when we browse the site of web2.0, but how does this tag be implemented? At first I did not know that asked a lot of things did not get a result, and then to explore a method of their own is very simple, I wrote a few days ago a small system (www.88doc.com) to do the introduction, I first give the table structure (field type omitted):
Cms_tag table: tag_id,tag_name,article_id;
Cms_tag_article table: id,tag_id,article_id;
Article table does not have to say and tag no direct relationship, we are concerned about the Cms_tag_article table, this is a relational table, the function is to let cms_tag and article table many-to-many relationship. In this way, when adding article to tag also added to the cms_tag_article also add a relationship, so that the article display page can also query out the relevant tags of the article, you can also query out all the articles containing a tag.
Currently www.88doc.com is the way to do the tag system. If a friend has a better way, please advise.