Answer the question
In order to leave comments, you need to log in
What is the best way to organize communication: article-category?
I am using Yii2.
There is a model Article (article) and Category (category).
What is the best way to organize communication between them?
Options:
1. In the Article model, add the category_id field, where we enter the category ID.
2. Add an intermediate table articles_categories (category_id, article_id).
The advantage of the first option is the ease of working with categories and related articles.
Advantages of the second option: flexibility, no need to modify the Article when adding similar links (tags, authors, etc.), you can add several categories to one article.
I tend to the second option, but I want to hear your opinion.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question