a presentation on mongodb introduction - habilelabs

Post on 24-Jan-2018

674 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

INTRODUCTION TO

Ankit DhirCEO and Founder

Habilelabs.io

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.

OPERATIONAL DATABASE LANDSCAPE

Depth of Functionality

Key / Value

Wide Column MongoDB

RDBMS

Scala

bili

ty a

nd P

erf

orm

ance

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.

CONCEPT MAPPING

MongoDB RDBMS

Database Database

Collection Table

Document Record/Row

Field Column

Embedded documents, linking Joins

DATABASE

• Made up of Multiple Collections.

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

COLLECTION

• Schema-less, and contains Documents.

• Indexable by one/more keys.

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

DOCUMENT

• Stored in a Collection.

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

• Supported Relationships

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

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

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.

Single View Internet of Things Mobile Real-Time Analytics

Catalog Personalization Content Management

MongoDB Use Cases

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

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.

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)

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

QUERY

• Rich JavaScript based Query syntax

• Allow us to deep, nested queries

• Example

• // find posts which has ‘MongoDB’ tag

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

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.

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/

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

top related