2. Agenda
Intro
Concepts & Rationale
● What is Mongodb, evolution,
Key Features
● Internals, crud operations, data management, security, provisioning and
disaster recovery
6. 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
7. Why Documents?
● Documents (i.e. objects) correspond to native data types in many
programming languages.
● Embedded documents and arrays reduce need for expensive joins.
● Dynamic schema supports fluent polymorphism.
10. Internals
Database - database
● Made up of multiple collections
● Created on the fly when referenced for the first time
Collection - Table
● Schemaless - Contains documents
● Indexable
● 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)
11. internals
Restrictions
● 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.
12. CRUD Operations
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.insert()
● db.collection.insertOne() New in version 3.2
● db.collection.insertMany() New in version 3.2
13. CRUD Operations
Read operations retrieves documents from a collection; i.e. queries a collection for
documents. MongoDB provides the following methods to read documents from a
collection:
● db.collection.find()
14. CRUD Operations
Update operations modify existing documents in a collection. MongoDB provides
the following methods to update documents of a collection:
● db.collection.update()
● db.collection.updateOne() New in version 3.2
● db.collection.updateMany() New in version 3.2
● db.collection.replaceOne() New in version 3.2
15. CRUD Operations
Delete operations remove documents from a collection. MongoDB provides the
following methods to delete documents of a collection:
● db.collection.remove()
● db.collection.deleteOne() New in version 3.2
● db.collection.deleteMany() New in version 3.2
16. Data Management
● 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)
17. Security
● 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
18. 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
running operations
● 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.
19. MongoDB Atlas
DB as a service
Automated operations - deploy in minutes
Elastic - easy to scale up or out
Performance metrics in real time