You need to write a forum using JSP and MongoDB database. Advise how best to proceed, create one collection for the entire forum and work with it, or several collections? For sections, topics, and replies for topics. Maybe there are other ideas?

    3 answers 3

    Hello! It will depend on the functionality that you want to implement on your forum.

    Example: At the forum, users must be present, therefore there must be a table (collection) of users with data on them. Users can leave messages - there will be a table of messages, etc. Of course, I'm not very good at NoSql solutions, but I think the analogy is clear)

      Here the main thing to sit down and write on a piece of paper:

      1. what types of content will be (users, news, forum post, comments)
      2. which ones will be used separately

      Since each created document will receive its own _id , which will be indexed, and the more indices - the greater the size of the database and the search time (although it’s about milliseconds, but still), you need to distinguish between content that needs _id and one that is not.

      For example: in MySQL, the comment will be in a separate table. In Monge, you can also create a collection of "db.comments", where every comment will receive an _id for which we will pull it. And you can just shove it into the post itself, because this type of content will not be used anywhere else.

      forum_post: { title: "Название поста", body: "Lorem Ipsum", comments:[ {author: "Ivan", body: "comment"}] } 

        There is another idea. Do not use for the mongo forum. It makes no sense.