了解 MongoDB(以及一般的 NoSQL)以及如何充分利用它
我开始认为我想做的下一个项目使用 NoSQL 解决方案会更好。该项目要么涉及大量的 2 列表,要么涉及传统 SQL 数据库中动态生成的列的大量动态查询。所以我觉得NoSQL数据库会干净得多。
我正在研究 MongoDB,它看起来很有前途。无论如何,我正在尝试理解这一切。另外,我将在 Ruby 中使用 MongoMapper。
不管怎样,我对如何在这样一个自由格式的数据库中布局事物感到困惑。我读过 NoSQL 最佳实践,那里的答案说规范化在 NoSQL DB 中通常很糟糕。那么,如何布局一个包含用户、帖子和评论的简单博客的最佳方式呢?
我的自然想法是每个集合都有三个集合,然后通过唯一的 ID 将它们链接起来。但这显然是错误的?那么,有哪些方法可以布置这样的事情呢?我对另一个问题给出的答案的担忧是,如果作者的名字改变了怎么办?您必须更新大量帖子和评论。但这对于 NoSQL 来说是一件好事吗?
I am beginning to think that my next project I am wanting to do would work better with a NoSQL solution. The project would either involve a ton of 2-column tables or a ton of dynamic queries with dynamically generated columns in a traditional SQL database. So I feel a NoSQL database would be much cleaner.
I'm looking at MongoDB and it looks pretty promising. Anyway, I'm attempting to make sense of it all. Also, I will be using MongoMapper in Ruby.
Anyway though, I'm confused as to how to layout things in such a freeform database. I've read NoSQL best practices and the answer there says that normalization is usually bad in a NoSQL DB. So how would be the best way of laying out say a simple blog with users, posts, and comments?
My natural thought was to have three collections for each and then link them by a unique ID. But this apparently is wrong? So, what are some of the ways to lay out such a thing? My concern with the answer given in the other question is, what if the author's name changed? You'd have to go through updating a ton of posts and comments. But is this an okay thing to do with NoSQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我找到了两个有用的页面 架构设计 和 数据建模(RoR 中的完整应用程序)
另外,#mongodb IRC 上的频道非常有帮助。那里的用户
dacort
帮助我找到了那些非常有用的页面。Ok, I've found two pages that are helpful Schema Design and Data Modeling (a full application in RoR)
Also, the #mongodb channel on IRC is extremely helpful. The user
dacort
there helped me to find those very useful pages.以下是 MongoDB 中 DBRef 的使用说明:http://valyagolev.net/article/mongo_dbref/
Here an explanation of the use of DBRefs in MongoDB: http://valyagolev.net/article/mongo_dbref/