Introduction to MongoDB
Welcome to the MongoDB 4.2 Manual! MongoDB is adocument database designed for ease of developmentand scaling. The Manual introduces key concepts in MongoDB, presents thequery language, and provides operational and administrativeconsiderations and procedures as well as a comprehensive referencesection.
MongoDB offers both a Community and an Enterprise version of thedatabase:
- MongoDB Community is the source available and free to use edition of MongoDB.
- MongoDB Enterprise is available as part of the MongoDB EnterpriseAdvanced subscription and includes comprehensive support for yourMongoDB deployment. MongoDB Enterprise also adds enterprise-focusedfeatures such as LDAP and Kerberos support, on-disk encryption,and auditing.
Document Database
A record in MongoDB is a document, which is a data structure composedof field and value pairs. MongoDB documents are similar to JSONobjects. The values of fields may include other documents, arrays,and arrays of documents.
The advantages of using documents are:
- Documents (i.e. objects) correspond to native data types inmany programming languages.
- Embedded documents and arrays reduce need for expensive joins.
- Dynamic schema supports fluent polymorphism.
Collections/Views/On-Demand Materialized Views
MongoDB stores documents in collections.Collections are analogous to tables in relational databases.
In addition to collections, MongoDB supports:
- Read-only Views (Starting in MongoDB 3.4)
- On-Demand Materialized Views (Starting in MongoDB 4.2).
Key Features
High Performance
MongoDB provides high performance data persistence. In particular,
- Support for embedded data models reduces I/O activity on databasesystem.
- Indexes support faster queries and can include keys from embeddeddocuments and arrays.
Rich Query Language
MongoDB supports a rich query language to support read and writeoperations (CRUD) as well as:
High Availability
MongoDB’s replication facility, called replica set, provides:
- automatic failover
- data redundancy.
A replica set is a group ofMongoDB servers that maintain the same data set, providing redundancyand increasing data availability.
Horizontal Scalability
MongoDB provides horizontal scalability as part of its _core_functionality:
- Sharding distributes data across acluster of machines.
- Starting in 3.4, MongoDB supports creating zones of data based on the shard key. In abalanced cluster, MongoDB directs reads and writes covered by a zoneonly to those shards inside the zone. See the Zonesmanual page for more information.
Support for Multiple Storage Engines
MongoDB supports multiple storage engines:
- WiredTiger Storage Engine (including support forEncryption at Rest)
- In-Memory Storage Engine.
In addition, MongoDB provides pluggable storage engine API that allowsthird parties to develop storage engines for MongoDB.