Mongodb SNS design problem

  mongodb, question

When making a small social networking site, you need to involveUserAndstate,CommentAfter waiting for several tables, users can publish multiple states, and each state will have multiple comments.
AboutstateTables andCommentThe design of the table has encountered some problems, namely, whether the user information is similar to the user name and user’s head portrait, etc. should be embeded in two tables, or whether only the user’s ID information is stored in the table.
There are now two solutions:

  • Only the user ID is stored in the two tables, and the specific information of the user is stored in the user table. However, this scheme will affect the efficiency when querying, especially when accessing a state specifically, all comments of that state must be obtained, and each comment must have the user’s avatar and nickname, etc. If querying separately each time, the efficiency will be very low.
  • It is very convenient to store the user’s information in two tables when querying, but it is very troublesome for users to update their own status. We have to go through these two tables to update the information one by one.

I don’t know which scheme should be chosen. Or is there a better plan?

State is a sub-array document, and sub-document array with comments in a single state.