I
I
Ivan Antonov2015-03-21 11:11:28
PHP
Ivan Antonov, 2015-03-21 11:11:28

How to organize work with tags?

The site is planned to organize tags:

  • In the article description, when you hover over a tag, a tooltip with a preview image of the tag will pop up. Tags can also be links to a product page.
  • In the list, it will be possible to check the boxes with which tags to show articles.

Tags can be arbitrary.
Interested in how best to store these tags and how to search for some of them.
At the moment, the following plan has matured in my head:
Create a tags table that will describe each tag with a link to an image and the tag name will be a unique index (for quick lookup). Create a tags field in the article table, where tag names are stored separated by commas.

The plan seems to be simple and clear, but how to implement the loading of the description for each tag, separated by commas, and how to search by:
  • Articles containing the selected tags
  • Articles containing ONLY selected tags

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RR, 2015-03-21
@antonowano

tags
-id
-name
-img
....
tags_relationships
-article_id
-tag_id
i.e. a table with tags and a separate table where you specify the relationship between the ID of a particular article and the ID of a particular tag

M
Mikhail Osher, 2015-03-21
@miraage

many-to-many

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question