4. www.edureka.in/mongodbSlide 4
How it Works….
Online Instructor–led Live classes
Class Recordings in Learning Management System (LMS)
Module–wise Quizzes and Practical Assignments
24x7 On–demand Technical Support
Project Based Verifiable Graded Certificate
Lifetime Access to the Learning Management System
5. www.edureka.in/mongodbSlide 5
Topics of the Day
Database Categories
Mongo DB Overview
Design Goals for MongoDB Server and Database
Mongo DB Tools
Introduction to JSON and BSON
Installation of MongoDB on Windows, Linux, MAC,OS etc.
Environment Setup for MongoDB
11. www.edureka.in/mongodbSlide 11
Schema - Free Easy – Replication Simple API
Can Manage Huge
Amount of Data
Can be implement on
Commodity Hardware's
~ 150 No SQL Database
are there in Market
Schema – Free !
~150
What is NoSQL?
18. www.edureka.in/mongodbSlide 18
Graph
Store
Key –
value
Stores
Wide
Column
Stores%
Document
Base
Document databases pair each key with a complex
data structure known as a document.
Documents can contain many different key-value
pairs, or key-array pairs, or even nested documents.
Graph stores are used to store information about
networks, such as social connections.
Graph stores include Neo4J and HyperGraphDB.
Key-value stores are the simplest NoSQL
databases.
Every single item in the database is stored as an
attribute name (or "key"), together with its value.
Wide-column stores such as Cassandra and
HBase are optimized for queries over large
datasets, and store columns of data together,
instead of rows.
Categories of NoSQL Database
20. www.edureka.in/mongodbSlide 20
Entity SQL Databases NoSQL Databases
Type One Type (SQL) with Minor Variation Many Types (Document, Ke-Value, Tabular, Graph)
Development 1970 2000
Examples Oracle, MSSQL, DB2 etc. MongoDB, Cassandra, Hbase, Neo4J
Schemas Fixed Dynamic
Scaling Vertical Horizontal
Dev Model Mix Open Source
Consistency Follow ACID Follow BASE
NoSQL vs. SQL Comparison
21. www.edureka.in/mongodbSlide 21
ACID Property
Atomic
A transaction is a logical unit
of work which must be either
completed with all of its data
modifications, or none of
them is performed.
Consistent
At the end of the transaction,
all data must be left in a
consistent state.
Isolated
Modifications of data
performed by a transaction
must be independent of
another transaction. Unless
this happens, the outcome of
a transaction may be
erroneous.
Durable
When the transaction is
completed, effects of the
modifications performed by
the transaction must be
permanent in the system.
Durable
Isolated
SQL Databases (ACID Property)
22. www.edureka.in/mongodbSlide 22
We must understand the CAP
theorem when we talk about
NoSQL databases or in fact
when designing any distributed
system.
CAP theorem states that there are 3 basic requirements which exist in a special relation when designing
applications for a distributed architecture.
Consistency
Availability
Partition
Tolerance
Cap Theorem
This means that the system is always on (service guarantee
availability), no downtime.
This means that the system continues to function even the
communication among the servers is unreliable, i.e. the servers
may be partitioned into multiple groups that cannot communicate
with one another.
This means that the data in the database remains consistent after
the execution of an operation. For example after an update
operation all clients see the same data.
23. www.edureka.in/mongodbSlide 23
In theoretically it is impossible to fulfill all 3 requirements.
CAP provides the basic requirements for a distributed system
to follow 2 of the 3 requirements.
Therefore all the current NoSQL database follow the different
combinations of the C, A, P from the CAP theorem.
Cap Theorem
24. www.edureka.in/mongodbSlide 24
CA - Single site cluster, therefore all nodes are always
in contact. When a partition occurs, the system blocks.
CP - Some data may not be accessible, but the rest is
still consistent/accurate.
AP - System is still available under partitioning, but
some of the data returned may be inaccurate.
Here is the brief description of three combinations CA, CP, AP :
Cap Theorem
25. www.edureka.in/mongodbSlide 25
Basically Available indicates that the system does guarantee availability, in terms of
the CAP theorem.
Basically Available
Soft State indicates that the state of the system may change over time, even without
input. This is because of the eventual consistency model.
Soft State
Eventual Consistency indicates that the system will become consistent over time,
given that the system doesn't receive input during that time.
Eventual Consistency
A BASE system gives up on consistency.
BASE
30. www.edureka.in/mongodbSlide 30
Right Data Model
Pros and Cons of Consistent
Compromising
Features of RDBMS
Step 2
Step 3
Before Selection and Implementation of NoSQL
Step 1
35. www.edureka.in/mongodbSlide 35
Mongo DB is an Open-source
database.
Developed by 10gen, for a wide
variety of applications.
It is an agile database that
allows schemas to change
quickly as applications evolve.
Scalability, High Performance and
Availability.
By leveraging in-memory computing. MongoDB’s native replication
and automated failover enable
enterprise-grade reliability and
operational flexibility.
MongoDB Overview
Overview
40. www.edureka.in/mongodbSlide 40
Built-In
Replication for
High Availability
Drivers: 13
MongoDB-Supported
Drivers; 37
Community-
Supported
Drivers
Hadoop
Integration
Aggregation
Framework &
Native
MapReduce
Rich Secondary
Indexes,
including
geospatial and
TTL indexes
Auto-Sharding
for Horizontal
Scalability
JSON Data
Model with
Dynamic
Schemas
MongoDB Features
41. www.edureka.in/mongodbSlide 41
Applications
Analytical Tools, BI Apps, Mobile Apps, CRM, ERP etc.
Data Management
Online Data Offline Data
Infrastructure
OS & Virtualization, Storage, Network etc.
Management&Monitoring
Security&Auditing
Mongo
dMongo
dMongod
RDMS
RDMS
RDMS
DWDWEDW
MongoDB High Level Architecture
45. www.edureka.in/mongodbSlide 45
MongoDB Enterprise is the commercial edition of MongoDB that provides
enterprise-grade capabilities.
MongoDB Enterprise includes advanced security features, management
tools, software integrations and certifications.
These value-added capabilities are not included in the open-source
edition of MongoDB.
MongoDB Enterprise
47. www.edureka.in/mongodbSlide 47
Features MongoDB MongoDB Enterprise
JSON Data Model with Dynamic Schemas • •
Auto-Sharding for Horizontal Scalability • •
Built-In Replication and High Availability • •
Full, Flexible Index Support • •
Rich Document Queries • •
Fast In-Place Updates • •
Aggregation Framework and MapReduce • •
Large Media Storage with GridFS • •
Text Search • •
Cloud, On-Premise and Hybrid Deployments • •
Role-Based Privileges • •
Advanced Security with Kerberos •
On-Prem Management •
SNMP Support •
OS Certifications •
Private On-Demand Training •
MongoDB Enterprise Includes
50. www.edureka.in/mongodbSlide 50
Annie’s Answer
1. Facebook ingests 500 terabytes of new data
every day.
2. A Boeing 737 will generate 240 terabytes of
flight data during a single flight across the US.
52. www.edureka.in/mongodbSlide 52
Metlife uses MongoDB for “The Wall” an innovative customer service application
provides a 360-degree, consolidated view of MetLife customers, including policy
details and transactions across lines of business.
ebay has a number of projects running on MongoDB for search suggestions,
metadata storage, cloud management and merchandizing categorization.
MongoDB is the repository that powers MTV Networks’ next-generation CMS,
which is used to manage and distribute content for all of MTV Networks’ major
websites.
MongoDB is used for back-end storage on the SourceForge front pages, project
pages, and download pages for all projects.
Craigslist uses MongoDB to archive billions of records.
ADP uses MongoDB for its high performance, scalability, reliability and its ability to
preserve the data manipulation capabilities of traditional relational databases.
Few MongoDB Clients
53. www.edureka.in/mongodbSlide 53
CNN Turk uses MongoDB for its infrastructure and content management system,
including the tv.cnnturk.com.
Foursquare uses MongoDB to store venues and user ‘check-ins’ into venues,
sharding the data over more than 25 machines on Amazon EC2.
Justin.tv is the easy, fun, and fast way to share live video online. MongoDB
powers Justin.tv’s internal analytics tools for virality, user retention, and general
usage stats that out-of-the-box solutions can’t provide.
ibibo (‘I build, I bond’) is a social network using MongoDB for its dashboard
feeds. Each feed is represented as a single document containing an average of
1000 entries; the site currently stores over two million of these documents in
MongoDB.
Few MongoDB Clients
55. www.edureka.in/mongodbSlide 55
Risk Analytics and Reporting
Reference Data Management
Market Data Management
Portfolio Management
Order Capture
Time Series Data
Financial Services
56. www.edureka.in/mongodbSlide 56
Surveillance Data Aggregation
Crime Data Management and Analytics
Citizen Engagement Platform
Program Data Management
Healthcare Record Management
Government
57. www.edureka.in/mongodbSlide 57
360-Degree Patient View
Population Management for At-Risk Demographics
Lab Data Management and Analytics
Mobile Apps for Doctors and Nurses
Electronic Healthcare Records (EHR)
Health Care
58. www.edureka.in/mongodbSlide 58
Content Management and Delivery
User Data Management
Digital Asset Management
Mobile and Social Apps
Content Archiving
Media and Entertainment
59. www.edureka.in/mongodbSlide 59
Rich Product Catalogs
Customer Data Management
New Services
Digital Coupons
Real-Time Price Optimization
Retail
70. www.edureka.in/mongodbSlide 70
Mongod is the primary daemon process for the MongoDB system.
Database is a physical container for collections.
Each database gets its own set of files on the file system.
A single MongoDB server typically has multiple databases.
It handles data requests, manages data format, and performs
background management operations.
mongod
MongoDB Database
71. www.edureka.in/mongodbSlide 71
Collection is a group of MongoDB documents.
It is the equivalent of an RDBMS table.
A collection exists within a single database.
Collections do not enforce a schema.
Documents within a collection can have different fields.
Typically, all documents in a collection are of similar or
related purpose.
mongod
Collection 1
Collection 2
Collection 3
Collection 4
Collection 5
Collection
……..n
MongoDB Collection
72. www.edureka.in/mongodbSlide 72
A document is a set of key-value pairs.
Documents have dynamic schema.
Collection 1
Collection 2
Collection 3
Collection 4
DOC 1
DOC 4DOC 5DOC 6
DOC 2DOC 3 DOC 7DOC 8DOC 9
DOC 10DOC 11DOC 12
MongoDB Document
73. www.edureka.in/mongodbSlide 73
{
_id: ObjectId(7df78ad8902c)
title: 'edureka',
description: 'Leading Training Provider Across Glob',
by: 'edureka',
url: 'http://www.edureka.in',
tags: ['mongodb', 'database', 'NoSQL'],
likes: 100,
comments: [
{
user:'user1',
message: 'My first comment',
dateCreated: new Date(2011,1,20,2,15),
like: 0
},
{
user:'user2',
message: 'My second comments',
dateCreated: new Date(2011,1,25,7,45),
like: 5
}
]
}
MongoDB Sample Document
74. www.edureka.in/mongodbSlide 74
RDBMS MongoDB
Database Database
Table Collection
Tuple/Row Document
Column/Attribute/Variable Field
Table Join Embedded Documents
Database Server and Client
Primary Key
Primary Key (Default key _id provided by mongodb
itself)
Mysqld/Oracle mongod
mysql/sqlplus mongo
RDBMS Terminology with MongoDB
81. www.edureka.in/mongodbSlide 81
Binary JavaScript
Object Notation
BJSON Abbreviation Supports the embedding of
documents and arrays within
other documents and arrays
Easy for machines to
parse and generate
Text format that is completely
language independent
Contains extensions that allow
representation of data types that
are not part of the JSON spec
BSON
85. www.edureka.in/mongodbSlide 85
Running MongoDB on Windows
Installation of MongoDB on Windows as a Service
Running of MongoDB on Linux (CentOS)
Installation of MongoDB on CentOS
MongoDB Installation – Live Demo
87. www.edureka.in/mongodbSlide 87
More on MongoDB
http://docs.mongodb.org/manual/
http://www.tutorialspoint.com/mongodb/
http://en.wikipedia.org/wiki/MongoDB
Connection with PHP to MongoDB
http://www.php.net/manual/en/mongo.tutorial.connecting.php
NoSQL Databases
http://www.w3resource.com/mongodb/nosql.php
http://www.dataversity.net/acid-vs-base-the-shifting-ph-of-database-transaction-
processing/
Big Data
http://en.wikipedia.org/wiki/Big_Data
Further Reading
88. www.edureka.in/mongodbSlide 88
Tasks for you
Attempt the following Assignments using the documents present in the LMS:
Write a JSON document which can have all data types supported by JSON?
What all core differences are there in MongoDB, Hadoop, HBase and Cassandra?
How can you define Horizontal & Vertical Scalability?
Can we design a Social Media App with MongoDB, if yes then how?
To design a content management system what all databases can be used and why?
I want to create a solution for Data Hub and I have choice of MySQL, Hadoop, Cassandra,
MongoDB, HBase, which one is more suitable and why?
What is Online & Offline Big Data?
What is Agility, What is tailored and elastic?
Assignments
89. www.edureka.in/mongodbSlide 89
MongoDB Installation on Windows or MongoDB Installation
on Centos
Generate Test Data on MongoDB Database
Execute all Module1 Script present in LMS
Read FAQ Module1 in LMS
Read FAQ Module1 in LMS
Take Quiz in LMS
Complete Assignment
Pre-work: Module 2
90. www.edureka.in/mongodbSlide 90
Agenda of Next Class
MongoDB Development Overview
MongoDB Production Overview
MongoDB CRUD Introduction
MongoDB CRUD Concepts
MongoDB CRUD Syntax & Queries
Module 2
CRUD Operations