MongoDB:“很少"之间的限制在哪里?和“许多"? [英] MongoDB : where is the limit between "few" and "many"?

查看:21
本文介绍了MongoDB:“很少"之间的限制在哪里?和“许多"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自关系数据库世界(Rails/PostgreSQL)并过渡到 NoSQL 世界(Meteor/MongoDB),所以我正在学习非规范化、嵌入和真正的链接.

I am coming from the relational database world (Rails / PostgreSQL) and transitioning to the NoSQL world (Meteor / MongoDB), so I am learning about denormalization, embedding and true links.

似乎在许多情况下,在各种数据库模式之间进行选择归结为彼此相关"的文档数量.

It seems that, in many cases, choosing between various database schemas comes down to the number of documents that will be "related" to each others.

在这个视频系列中,作者区分:

  • one-to-many 关系来自 one-to-few 关系
  • many-to-many 关系来自 few-to-few 关系
  • one-to-many relationships from one-to-few relationships
  • many-to-many relationships from few-to-few relationships

所以,我想知道:fewmany 之间的界限在哪里?

So, I am wondering: where is the limit between few and many?

我想可能没有一个硬数字,但我们是几十、几百、几千还是几百万?

I guess there may not be a hard number, but are we in the dozens, the hundreds, the thousands or the millions?

推荐答案

这都是相对的,在设计架构时做出假设确实是一个危险的问题.值得花时间为您的架构和设置做出正确的选择.我会建议几个步骤:

It's all relative and is really kind of a dangerous question to make assumptions about when you're designing an architecture. It's worth investing time to make the right choices for your schema and your setup. I would advise a few steps:

  1. 算一算.根据您期望您的应用程序需要做什么来增加您的关系.如果您有一些嵌套数组或嵌入文档,那么当您开始 $unwinding 时,一对一对多"可以很容易地扩展到多个文档.

  1. Do the math. Multiply your relationships out based on what you expect your application to need to do. If you have a few nested arrays or embedded documents, a couple of "one-to-few" can expand out to many documents pretty easily when you start $unwinding them.

写一个原型.在您对所有数据进行查询时,对您预期的硬件/环境进行一些基本测试,看看它是否可以轻松处理该负载.

Write a prototype. Do some basic testing on your expected hardware/environment to see if it can easily handle that load when you do queries for all the data.

根据您的测试,创建限制.这是您需要在系统崩溃之前为每个文档、每种关系类型创建多少个关系划定界限的地方.

Based on your testing, create the limitations. This is where you need to draw the line on how many relations you can create per document, for each relationship type, before the system breaks down.

如果是我,我会说一对多少于一打,一对多理论上是无限的,但实际上是数百万.也许应该有一个一对多"的中间立场来表示可能有数百个.

If it were me, I would say one-to-few is less than a dozen, and one-to-many is theoretically unlimited, but practically in the millions. Maybe there should be a middle ground of "one-to-some" to indicate possibly hundreds.

这篇关于MongoDB:“很少"之间的限制在哪里?和“许多"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆