Y
Y
yellow_pus2022-04-02 16:29:20
Database design
yellow_pus, 2022-04-02 16:29:20

How to properly organize communication?

The idea came to mind, I wanted to implement something like "categories and articles", but with the condition that the article can have several categories. I know that there is such a type of relationship as "many to many", that is, separately we have 1) a table of articles 2) a table of categories 3) a table of categories and articles. In the 3rd table, you can put the article_id and category_id, but where to put the rest of the categories (for example, their maximum can be 5)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alan Gibizov, 2022-04-02
@yellow_pus

If you have an article article_1 and it belongs to the three categories category_1, category_2 and category_3, you will have three records in the intermediate table:

# | articles  | categories
————————————-————————————-
1 | article_1 | category_1
2 | article_1 | category_2
3 | article_1 | category_3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question