K
K
Kurper2020-01-16 18:25:03
MySQL
Kurper, 2020-01-16 18:25:03

What is the best way to create trees for different categories?

Hello.
I just wanted to ask for advice on what is better to use to create categories ... For example, there is a list of posts, each post has categories (Scientific, Entertaining ...), and as an example, make additional categories for whom this post is for (Schoolchildren, Housewives ...). Perhaps there will be some other tree of categories not for posts, but for news, menus ... That's actually the question, how to store all these categories, or rather, what is the best way? I don’t want to create different tables for different categories, but is it worth storing in one or not (I mean a separate tree for each category)?
That is, it turns out that now I have at least two category trees (there may be subcategories), and maybe even more.
Looked towards Yii2 Materialized Path, it seems not a bad decision ... Maybe someone has come across this, or will advise something else.
PS with posts it's just an example :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-01-16
@Kurper

Use NestedSets. There is a good solution for YIi paulzi/yii2-nested-sets

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question