Answer the question
In order to leave comments, you need to log in
Question about mongodb database structure
Now I'm trying to get into mongodb, but something is not entirely clear. I think that there are many experts on this DBMS on Habré, so I think that the question is appropriate. So, a simple situation - a simple forum.
We store sections, topics and messages in the database. The question is, what is the best way to store these data? 3 different collections, or 1 collection section->list_of_topics->list_of_messages_to_each_topic? If you use the second option, then judging by the answers to my question, we will not be able to select all the messages of the selected topic with one request, we will need to filter out a large amount of information. And if we take the first option, then we start working with the database as with a relational one?
Answer the question
In order to leave comments, you need to log in
Store in different collections. Especially if the forum means pages like "all user posts" or "all user topics". Yes, the structure is similar to a relational database, but there is nothing wrong with that. The main advantages of this DBMS (the ability to create arbitrary additional properties, especially array properties, and build indexes on them, including partial ones) are not lost.
I'm going to warn you right now that I'm not an expert.
It is necessary to build on what is primary on the forum and what are the main entities. I think that the main thing is the user and his message. Therefore, two collections are exactly - users and messages.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question