MongoDB is a database management system designed for web applications and internet infrastructure. The data model and persistence strategies are built for high read and write throughput and the ability to scale easily with automatic failover.
Document-based data model can represent rich, hierarchical data structures, it’s often possible to do with-
out the complicated multi-table joins imposed by relational databases.
key features
The document data model
Ad hoc queries
Ad hoc queries is to say that it’s not necessary to define in advance what sorts of queries the system will accept.Forinstance, key-value stores are queryable on one axis only: the value’s key. Like many other systems, key-value stores sacrifice rich query power in exchange for a simple scalability model. One of MongoDB’s design goals is to preserve most of the query power that’s been so fundamental to the relational database world.
A SQL query would look like this:
SELECT * FROM posts INNER JOIN posts_tags ON posts.id = posts_tags.post_id INNER JOIN tags ON posts_tags.tag_id == tags.id WHERE tags.text = 'politics' AND posts.vote_count > 10;
The equivalent query in MongoDB is:
db.posts.find({'tags': 'politics', 'vote_count': {'$gt': 10}});
Secondary indexes
Once your data set grows to a certain size, indexes become necessary for query efficiency. Proper indexes will increase query and sort speeds by orders of magnitude;consequently, any system that supports ad hoc queries should also support secondary indexes.
Secondary indexes in MongoDB are implemented as B-trees.With MongoDB, you can create up to 64 indexes per collection.
Replication
MongoDB provides database replication via a topology known as a replica set. Replica sets distribute data across machines for redundancy and automate failover in the event of server and network outages. Additionally, replication is used to scale database reads. If you have a readintensive application, as is commonly the case on the web, it’s possible to spread database reads across machines in the replica set cluster.
Replica sets consist of exactly one primary node and one or more secondary nodes.a replica set’s primary node can accept both reads and writes, but the secondary nodes are read-only. What makes replica sets unique is their support for automated failover: if the primary node fails, the cluster will pick a secondary node and automatically promote it to primary. When the former primary comes back online, it’ll do so as a secondary.
Speed and durability
Write speed can be understood as the volume of inserts, updates,and deletes that a database can process in a given time frame. Durability refers to level of assurance that these write operations have been made permanent.
In MongoDB’s case, users control the speed and durability trade-off by choosing write semantics and deciding whether to enable journaling. All writes, by default, are fire-and-forget, which means that these writes are sent across a TCP socket without requiring a database response. If users want a response, they can issue a write using a special safe mode provided by all drivers. This forces a response, ensuring that the write has been received by the server with no errors. Safe mode is configurable; it can also be used to block until a write has been replicated to some number of servers. For high-volume, low-value data (like clickstreams and logs), fire-and-forget-style writes can be ideal. For important data, a safe-mode setting is preferable.
Scaling
The technique of augmenting a single node’s hardware for scale is known as vertical scaling or scaling up.horizontally, or scaling out is scaling horizontally means distributing the database across multiple machines.
MongoDB has been designed to make horizontal scaling manageable. It does so via a range-based partitioning mechanism, known as auto-sharding, which automatically manages the distribution of data across nodes. The sharding system handles the addition of shard nodes, and it also facilitates automatic failover. Individual shards are made up of a replica set consisting of at least two nodes,4 ensuring automatic recovery with no single point of failure.
The difference between various databases
相关推荐
What’s inside: The book will cover the process of understanding about Big Data, NoSQL and MongoDB in the following few steps: 1: Introduction to Big Data and NoSQL 2: Introduction to MongoDB 3: ...
1. **弹性伸缩**:MongoDB支持水平扩展,可以通过添加更多的服务器来增加处理能力和存储空间。 2. **高性能**:通过内存映射技术,MongoDB能够快速地读写数据,提供了极高的性能。 3. **高可用性**:MongoDB提供了...
在学习MongoDB时,你可以通过《MongoDB Introduction》这份PPT深入了解其基本概念、安装与配置、数据模型、CRUD操作(创建、读取、更新、删除)、索引创建、复制集和分片等核心内容。此外,通过阅读博客文章(如链接...
Practical Guide to MongoDB: Architecting, Developing, and Administering MongoDB begins with a short introduction to the basics of NoSQL databases and then introduces readers to MongoDB—the leading ...
With this authoritative introduction, you'll learn the many advantages of using document-oriented databases, and discover why MongoDB is a reliable, high-performance system that allows for almost ...
Need a quick and easy to understand introduction to MongoDB and NoSQL databases?... 1: Introduction to MongoDB Ch. 2: Installing MongoDB Ch. 3: The Data Model Ch. 4: Working with Data Ch. 5: GridFS
1. 分布式架构:MongoDB支持横向扩展,可以通过增加更多的服务器来提高性能和存储容量。这种水平扩展能力使其能够处理大规模数据集。 2. 自动分片(Sharding):MongoDB提供了自动分片功能,可以将大型数据集分散到...
MongoDB is a document-oriented database management system designed ...If you’d like to learn how to use MongoDB with your programming language of choice, see the introduction to the drivers (page 393).
Chapter 1: Fundamentals 1.1Definition of the Data Layer 1.2 Data layer design process 1.3Introducing MongoDB 1.4The MongoDB Collection 1.5The MongoDB Document Chapter2: Data Modeling 2.1 Referencing ...
1: Introduction to MEAN 2: Getting Started with Node.js 3: Building an Express Web Application 4: Introduction to MongoDB 5: Introduction to Mongoose 6: Managing User Authentication Using ...
- **第一章:Introduction(介绍)** - **知识点**: - **ARichDataModel(丰富的数据模型)**: MongoDB采用了面向文档的数据模型,支持嵌套结构,可以存储复杂的数据类型,如数组和对象。 - **EasyScaling...
- **Introduction**:MongoDB 简介。 - **Quickstart**:快速入门指南,包括不同操作系统的安装步骤。 - **Downloads**:下载页面,列出不同版本的发布说明。 - **Drivers**:支持的各种语言驱动程序介绍。 - *...
1. 引言(Introduction) 文档的引言部分概述了MongoDB的开发背景,强调了它不是在实验室里凭空设计出来的,而是基于实际构建大规模、高可用性和健壮系统的经验。它明确指出MongoDB不是从零开始开发的,而是尝试找...