21
INTRODUCTION TO Ankit Dhir CEO and Founder Habilelabs.io

A Presentation on MongoDB Introduction - Habilelabs

Embed Size (px)

Citation preview

Page 1: A Presentation on MongoDB Introduction - Habilelabs

INTRODUCTION TO

Ankit DhirCEO and Founder

Habilelabs.io

Page 2: A Presentation on MongoDB Introduction - Habilelabs

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.

Page 3: A Presentation on MongoDB Introduction - Habilelabs

OPERATIONAL DATABASE LANDSCAPE

Depth of Functionality

Key / Value

Wide Column MongoDB

RDBMS

Scala

bili

ty a

nd P

erf

orm

ance

Page 4: A Presentation on MongoDB Introduction - Habilelabs

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.

Page 5: A Presentation on MongoDB Introduction - Habilelabs

CONCEPT MAPPING

MongoDB RDBMS

Database Database

Collection Table

Document Record/Row

Field Column

Embedded documents, linking Joins

Page 6: A Presentation on MongoDB Introduction - Habilelabs

DATABASE

• Made up of Multiple Collections.

• Created on-the-fly when referenced for the first time.

Page 7: A Presentation on MongoDB Introduction - Habilelabs

COLLECTION

• Schema-less, and contains Documents.

• Indexable by one/more keys.

• Created on-the-fly when referenced for the first time.

Page 8: A Presentation on MongoDB Introduction - Habilelabs

DOCUMENT

• Stored in a Collection.

• Can have _id key – works like Primary keys in MySQL.

• Supported Relationships

Page 9: A Presentation on MongoDB Introduction - Habilelabs

HOW DOES MONGODB STORE DATA

• Data stored in BSON

• BSON is a binary serialization of JSON-like objects Monday

\x16\x00\x00\x00 // total document size

\x02 // 0x02 = type String

{"hello": "world"} → hello\x00 // field name

\x06\x00\x00\x00world\x00 // field value

\x00 // 0x00 = type EOO ('end of object')

• http://bsonspec.org

Page 10: A Presentation on MongoDB Introduction - Habilelabs

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

Page 11: A Presentation on MongoDB Introduction - Habilelabs

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.

Page 12: A Presentation on MongoDB Introduction - Habilelabs

Single View Internet of Things Mobile Real-Time Analytics

Catalog Personalization Content Management

MongoDB Use Cases

Page 13: A Presentation on MongoDB Introduction - Habilelabs

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

Page 14: A Presentation on MongoDB Introduction - Habilelabs

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.

Page 15: A Presentation on MongoDB Introduction - Habilelabs

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)

Page 16: A Presentation on MongoDB Introduction - Habilelabs

UNDERSTANDING THE DOCUMENT

• var doc = {‘_id’: ‘507f191e810c19729de860ea’,‘createdBy’: DBRef(‘User’, ‘907f191e710c19729de860ea’),‘name’: ‘Ankit Dhir’,‘empID’: ‘01 ‘,‘timestamp’: Date(’08-09-17’),‘tags’: [‘MongoDB’, ‘NoSQL’],‘comments’: [{

‘author’: DBRef(‘User’, ’, ‘407f191e710c19729de860ea’), ‘date’: Date(’ 08-09-17’), ‘text’: ‘Good‘, ‘upvotes’: 7

]}

ObjectId

Manual references

Page 17: A Presentation on MongoDB Introduction - Habilelabs

QUERY

• Rich JavaScript based Query syntax

• Allow us to deep, nested queries

• Example

• // find posts which has ‘MongoDB’ tag

• db.posts.find({tags: ‘MongoDB’});

Page 18: A Presentation on MongoDB Introduction - Habilelabs

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.

Page 19: A Presentation on MongoDB Introduction - Habilelabs

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/

Page 20: A Presentation on MongoDB Introduction - Habilelabs
Page 21: A Presentation on MongoDB Introduction - Habilelabs

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 : [email protected]

• Web : https://habilelabs.io

• Telephone: +91-9828247415 / +91-9887992695