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

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

问题描述

我来自关系数据库世界(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.

在此视频系列中,作者做出了以下区分:

In this video series, the author distinguishes:

    来自one-to-few关系的
  • one-to-many关系
  • 来自few-to-few关系的
  • many-to-many关系
  • 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:"few"和"few"之间的界限在哪里?和“很多"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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