What is the type of data in the cell where the tags are located?

In the mysql database, there are many articles in the table (the article - this is a lot of fields - the author’s name, text, date, and I also want to enter the tags field). And here, for example, there is a link on the page: called php and clicking on it I want the articles to appear in this new window with this tag.

And what if the article has a lot of tags: for example, php, mysql, etc ...

For example, I enter the tags field in the table ... so I do not know what kind of data should be in this cell? How to write them there (these tags)? Comma or how?

And how then from such a large number of tags to make the program understand that the line of tags is necessary and it is necessary to display this article?

    2 answers 2

    as an option, you can create a table of tags and store them there, and provide the user with a choice of tags from it, then select from the article's database in the text of which this tag is found, or in the name. or each article to select another column in the database to store its tags, then compare it with custom tags.

      Use this structure (pseudo-code) - and I think it will be clear how to achieve the result:

      Topic: { id: int, text: text, title: varchar(255) } Tag: { id: int, name: varchar(255) unique } TopicTag: { topic_id: int ForeignKey_Topic_id, tag_id: int ForeignKey_Tag_id } 

      IMHO: There are alternative names (typos, etc) tags. It was logical, if you enter to use the add. table:

       TagAlternative: { tag_id: int ForeignKey_Tag_id, name: varchar(255) unique } 
      • This option is the most correct of 2x - Artem
      • Thank you very much, timka_s! I will try) - qwerty17