I am creating an blogging application in Node.js + MongoDB Database. I have used relational Database like MySQL before but this is my first experience with NoSQL database. So I would like to conform my MongoDB data models before I move further.
I have decided my blogDB to have 3 collections
PostDB
{
_"id" : ObjectID(...),
"author": "author_name",
"Date": new Date(....),
"tag" : ["politics" , "war"],
"post_title": "My first Article",
"post_content": "Big big article"
"likes": 23
"access": "public"
}
CommentDB
{
"_id" : Objectid(...),
"POST": "My First Article",
"comment_by": "User_name",
"comment": "MY comments"
}
UserInfoDB
{
"_id": ObjectID(...),
"user": "User_name",
"password": "My_password"
}
I would appreciate your comments.
In your place, I would embed the Comments collection into the Posts collection. The disadvantage of this is if you have many many comments you could reach the limit of 16MB. The advantage is that you prejoined the data, so the query will be faster. You won't look for a comment without its post anyway.
Another thing is that you could make the "user" field the ID of the UserInfo collection. That way you will have a reference to a unique user in Comments.