B
B
bozuriciyu2019-10-15 16:03:35
MongoDB
bozuriciyu, 2019-10-15 16:03:35

How to build relationships, using the example of categories / tags?

We have a standard site content structure: posts, categories, tags.
Previously, I did this: I save a post, in its "categories / tags" field I specify the ID of the corresponding category / tag, and then in the category / tag itself in the "posts" field I push the post ID. Everything seemed to be ok. It was convenient, for example, to enter a category and make a lazy load by going through an array of posts.
But, now I am faced with a situation where I have 1 million posts. Accordingly, I'm in a stupor, because it looks pointless to have an array with a million items. Previously, I immediately received it on the client when I fetched a category / tag, but then there were a maximum of a couple of hundred posts, it was cheap ...
How to build a database in this case? Just make a link in the corresponding post to the category, and not store anything in the category itself? What options are there and how to do in such situations?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question