This document introduces MongoDB, an open-source document-oriented database. It discusses how MongoDB stores data as JSON-like documents rather than in tables, supports dynamic schemas, and is horizontally scalable. Some common use cases for MongoDB are also listed, including single view applications, IoT, mobile, real-time analytics, personalization, catalogs, and content management. The document concludes by covering how Habilelabs uses MongoDB with Node.js for REST API projects.
2. WHAT IS ?
• Scalable High-Performance Open-source, Document-orientated database.
• Built for Speed - the performance of traditional key-value stores while
maintaining functionality of traditional RDBMS
• Rich Document based queries for Easy readability.
• Full Index Support for High Performance.
• Replication and Failover for High Availability.
• Auto Shading for Easy Scalability.
• Map / Reduce for Aggregation.
4. WHY WE SHOULD USE MONGODB?
• SQL was invented in the 70’s to store data.
• MongoDB stores documents (or) objects.
• Now-a-days, everyone works with objects(Python/Ruby/Java/etc.)
• And we need Databases to persist our objects. Then why not store objects
directly ?
• Embedded documents and arrays reduce need for joins. No Joins and No-
multi document transactions.
6. DATABASE
• Made up of Multiple Collections.
• Created on-the-fly when referenced for the first time.
7. COLLECTION
• Schema-less, and contains Documents.
• Indexable by one/more keys.
• Created on-the-fly when referenced for the first time.
8. DOCUMENT
• Stored in a Collection.
• Can have _id key – works like Primary keys in MySQL.
• Supported Relationships
9. HOW DOES MONGODB STORE DATA
• Data stored in BSON
• BSON is a binary serialization of JSON-like objects Monday
x16x00x00x00 // total document size
x02 // 0x02 = type String
{"hello": "world"} → hellox00 // field name
x06x00x00x00worldx00 // field value
x00 // 0x00 = type EOO ('end of object')
• http://bsonspec.org
10. FLEXIBLE “SCHEMAS”
• Store and combine data of any structure
• No need of giving sophisticated validation rules
• You can dynamically modify the schema without downtime
• Fast, Iterative Development
• You spend less time prepping your data for the database, and more time
putting your data to work
11. WHAT ARE COMMON USE CASES FOR MONGODB?
• The most common use cases for MongoDB include
• Single View
• Internet of Things
• Mobile
• Real-Time Analytics
• Personalization
• Catalog
• Content Management.
12. Single View Internet of Things Mobile Real-Time Analytics
Catalog Personalization Content Management
MongoDB Use Cases
13. THE LARGEST ECOSYSTEM
• 10,000,000+
MongoDB Downloads
• 300,000+
Online Education Registrants
• 40,000+
MongoDB Cloud Manager Users
• 35,000+
MongoDB User Group Members
• 1,000+
Technology and Services Partners
• 2,000+
Customers Across All Industries
14. WHEN WOULD MYSQL BE A BETTER FIT?
• Applications that require complex, multi-row transactions (e.g., a double-
entry bookkeeping system)
• MongoDB is not a drop-in replacement for legacy applications built around
the relational data model and SQL.
15. SQL DATABASE VS MONGODB
SQL Database NoSQL Database
Relational database Non-relational database
Supports SQL query language Supports JSON query language
Table based Collection based and key-value pair
Row based Document based
Column based Field based
Support foreign key No support for foreign key
Support for triggers No Support for triggers
Contains schema which is predefined Contains dynamic schema
Not fit for hierarchical data storage Best fit for hierarchical data storage
Vertically scalable - increasing RAM Horizontally scalable - add more servers
Emphasizes on ACID properties (Atomicity,
Consistency, Isolation and Durability)
Emphasizes on CAP theorem (Consistency,
Availability and Partition tolerance)
17. QUERY
• Rich JavaScript based Query syntax
• Allow us to deep, nested queries
• Example
• // find posts which has ‘MongoDB’ tag
• db.posts.find({tags: ‘MongoDB’});
18. SOME COOL FEATURES
• Horizontally Scalable Architectures - no joins + no complex transactions
• Geo-spatial Indexes for Geo-spatial queries. $near, $within_distance, Bound
queries (circle, box)
• GridFS Stores Large Binary Files.
• Map/Reduce GROUP BY in SQL, map/reduce in MongoDB.
19. HOW DO WE USE MONGODB AT HABILELABS
• We use with Nodejs, generally as database of REST API Projects in MEAN stack
• We use mongoosejs object modelling which help us in writing MongoDB
validation, casting and business logic boilerplates
• http://mongoosejs.com/
20.
21. CONTACT US
• Development Center :
Habilelabs Pvt. Ltd.
4th Floor, I.G.M. Senior Secondary Public School Campus,
Sec-93 Agarwal Farm, Mansarovar, Jaipur(Raj.) – 302020
• Email : info@Habilelabs.io
• Web : https://habilelabs.io
• Telephone: +91-9828247415 / +91-9887992695