D
D
Denis Bukreev2017-04-20 10:07:59
Backend
Denis Bukreev, 2017-04-20 10:07:59

How to properly organize tags in the database and the selection?

I master the backend on a tangent, I write test projects for self-study.
Faced with the issue of organizing tags.
How to bind them, for example, to articles?
Do you need to create a separate table for them and indicate in this table the articles to which the tag is attached? Or indicate the id of the attached tags in the article?
Or in general, in one of the fields of the article, list the tags on one line with a separator?
Or maybe there are other ways?
I wonder which option is the most correct, effective .. logical. Well, it's easy to do.
Perhaps there is some functional difference in using tags with these methods? For example, it seems to me that if the tags have their own table, then it is easier to search.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin B., 2017-04-20
@denisbookreev

The most rational is to create three tables. posts, tags and post_tags

U
UksusoFF, 2017-04-20
@UksusoFF

https://github.com/spatie/laravel-tags

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question