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版)
8
2
在创建索引(尤其是在创建唯一索引)时,我们会采用一些文档结构。这些索引是按照每
个集合来定义的。通过只将单一类型的文档放入集合中,可以更高效地对集合进行索引。
创建模式并且将相关类型的文档放在一起是非常合理的。虽然默认情况下为应用程序定义
模式并非必需,但这是一种很好的实践,可以通过使用
MongoDB
的文档验证功能和可用
于多种编程语言的对象
文档映射(
object-document mapping
)库来实现。
2.2.2
 命名
集合由其名称进行标识。集合名称可以是任意
UTF-8
字符串,但有以下限制。
集合名称不能是空字符串(
""
)。
集合名称不能含有
\0
(空字符),因为这个字符用于表示一个集合名称的结束。
集合名称不能以
system.
开头
,该前缀是为内部集合保留的。例如,
system.users
集合中
保存着数据库的用户,
system.namespaces
集合中保存着有关数据库所有集合的信息。
用户创建的集合名称中不应包含保留字符
$
。许多驱动程序确实支持在集合名称中使用
$
,这是因为某些由系统生成的集合会包含它,但除非你要访问的是这些集合之一,否
则不应在名称中使用
$
字符。
子集合
使用
.
字符分隔不同命名空间的子集合是一种组织集合的惯例。例如,有一个具有博客功
能的应用程序,可能包含名为
blog.posts
和名为
blog.authors
的集合
。这只是一种组织管理
的方式,
blog
集合(它甚至不必存在)与其“子集合”之间没有任何关系。
尽管子集合没有任何特殊属性,但它们很有用,许多 ...
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