What is MongoDB
• Scalable High-Performance Open-source, Document-oriented database.
• Built for Speed
• Rich Document based queries for easy readability.
• Full Index Support for High Performance.
• Replication and Failover for High Availability.
• Auto Sharding for Easy Scalability.
• Map / Reduce for Aggregation.
Support for multiple storage engines
● Documents (i.e. objects) correspond to native data types in many
● Embedded documents and arrays reduce need for expensive joins.
● Dynamic schema supports fluent polymorphism.
Database - database
● Made up of multiple collections
● Created on the fly when referenced for the first time
Collection - Table
● Schemaless - Contains documents
● Created on the fly when referenced
Document - Row
● Stored in a collection
● Have _id - similar to primary keys
● Supports Relationships (embedded / referenced)
● Stored in BSON (Binary JSON)
● The field name _id is reserved for use as a primary key; its value must be unique in the collection, is immutable, and
may be of any type other than an array.
● The field names cannot start with the dollar sign ($) character.
● The field names cannot contain the dot (.) character.
● The field names cannot contain the null character.
Create - Create or insert operations add new documents to a collection. If the
collection does not currently exist, insert operations will create the collection.
MongoDB provides the following methods to insert documents into a collection:
● db.collection.insertOne() New in version 3.2
● db.collection.insertMany() New in version 3.2
Read operations retrieves documents from a collection; i.e. queries a collection for
documents. MongoDB provides the following methods to read documents from a
Update operations modify existing documents in a collection. MongoDB provides
the following methods to update documents of a collection:
● db.collection.updateOne() New in version 3.2
● db.collection.updateMany() New in version 3.2
● db.collection.replaceOne() New in version 3.2
Delete operations remove documents from a collection. MongoDB provides the
following methods to delete documents of a collection:
● db.collection.deleteOne() New in version 3.2
● db.collection.deleteMany() New in version 3.2
● Auto-Sharding (sharding) - automatically balances the data in the sharded
cluster as the data grows or the size of the cluster increases or decreases.
○ Range based - docs partitioned across shards according to the shard key value
○ Hash based - “ “ according to the MD5 hash of the shard key value
○ Zone Sharding - provides dba & ops teams w/ opportunities to define rules governing data
placement in a sharded cluster
● Availability - through Replication (replica sets)
○ Replica failover fully automated
○ No. of replica sets fully configurable (up to 50) - allows for data durability in case of failures
○ Replica sets allow for operational flexibility - db does not need to be taken offline
○ Allows for tunable consistency - apps reading from secondaries (data is consistent by default)
● Authentication - integration w/ LDAP, Kerberos
● Authorisation - admins can define user-based roles
● Auditing - audit log to track any op taken against the db
● Encryption - Data can be encrypted on the network, disk & in back ups
Provisioning, Monitoring and Disaster Recovery
Made possible by the Mongodb Ops Manager
● Deployment - Any topology, at any scale
● Upgrade - In minutes, with no downtime
● Scale - Add capacity, without taking the application offline
● Visualize - Graphically display query performance to identify and fix slow
● Point-in-time, Scheduled backups - restore complete running clusters to
any point in time with just a few clicks, because disasters aren't predictable
● Performance Alerts - Monitor 100+ system metrics and get custom alerts
before the system degrades.
DB as a service
Automated operations - deploy in minutes
Elastic - easy to scale up or out
Performance metrics in real time