Reputation: 313
I'm building a simple blog system for multiple users
, they can access data by userID
, username
and nodeID
(blog).
In RDBMS, normally we will have user
/table
/ownership
tables. In mongoDB, some suggest to put them in a single users
collection. However, as far as i know, it could be very slow if users
want to access specific nodeID
, since mongoDB may go through every document. Indexing will significantly drop the create speed, in my case, that means both createUser()
and createNode()
, right?
Therefore, is there any "Best Practices" we can follow? Thanks.
Upvotes: 2
Views: 3404
Reputation: 11159
Three Collections Inside the DB, Namely,
"Users",
"UserPosts",
"UserComments"
Users Collection's Field could be
"name",
"age",
"occupation",
"profileImage",
"numberOfPosts",
"birthdate",
"joiningDate",
"session"
etc.
UserPosts Collection's Field could be
"Id",
"revisionId",
"author",
"type",
"language",
"userId",
"status",
"title",
"tags",
"content"
etc.
UserComments Collection's Field could be
"Id",
"userPostId",
"author",
"type",
"language",
"userId",
"status",
"comment",
etc.
User Comment will be maintained by UserPostId Field It contains.
Upvotes: 4