我正在为多个users
构建一个简单的博客系统,他们可以通过userID
,username
和nodeID
(博客)访问数据。
在RDBMS中,通常我们会有user
/ table
/ ownership
个表。在mongoDB中,有些人建议将它们放在一个users
集合中。但是,据我所知,如果users
想要访问特定的nodeID
,可能会非常慢,因为mongoDB可能会遍历每个文档。在我的情况下,索引会显着降低创建速度,这意味着createUser()
和createNode()
,对吗?
因此,我们可以遵循“最佳实践”吗? 感谢。
答案 0 :(得分:2)
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.