Skip to Content
MongoDB权威指南(第3版)
book

MongoDB权威指南(第3版)

by Shannon Bradshaw, Eoin Brazil, Kristina Chodorow
November 2021
Intermediate to advanced
410 pages
12h 1m
Chinese
Posts & Telecom Press
Content preview from MongoDB权威指南(第3版)
176
9
结构存储在同一个文档的数组中。在电子商务网站的例子,特别是其产品目录中,通常
会有属于多个类别的产品或者这个产品的类别从属于其他某个类别。一个例子就是“硬
盘驱动器”,它本身是一个类别,但还属于“存储”类别,“存储”本身又属于“计算机
部件”类别,而这还是“电子”类别的一部分。在这种情况下,我们会有一个字段跟踪
整个层次结构,另一个字段保存直接类别(“硬盘驱动器”)。保存在数组中的整个层次
结构字段提供了对这些值使用多键索引的能力。这可以确保很容易地找到层次结构中与
类别相关的所有项目。直接类别字段允许找到与此类别直接相关的所有项目。
预分配模式
这主要用于
MMAP
存储引擎
,但仍然有一些可以使用此模式的场景。该模式建议创建
一个初始的空结构,稍后对该结构进行填充。例如,一个按天管理资源的预订系统可以
跟踪该资源是空闲的还是已预订
/
不可用的
。资源(
x
)和天数(
y
)的二维结构使得检
查是否可用以及执行计算变得非常简单。
文档版本控制模式
这种模式提供了一种机制来保留文档的旧版本。它需要在每个文档中添加一个额外的字
段来跟踪“主”集合中的文档版本,还需要一个额外的集合来保存文档的所有修订版
本。此模式具备以下假设:具体来说,每个文档都有有限数量的修订版本,不存在大量
需要版本控制的文档,并且查询主要是对每个文档的当前版本进行的。假如这些假设不
成立,那么可能需要修改模式或考虑使用不同的设计模式。
MongoDB
提供了一些关于模式和模式设计的有用的在线资源
MongoDB
大学提供了一个
免费课程——
M320 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

大数据项目管理:从规划到实现

大数据项目管理:从规划到实现

Ted Malaska, Jonathan Seidman
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉
Spark快速大数据分析(第2版)

Spark快速大数据分析(第2版)

Jules S. Damji, Brooke Wenig, Tathagata Das, Denny Lee
Kafka权威指南(第2版)

Kafka权威指南(第2版)

Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty

Publisher Resources

ISBN: 9787115576538