SlideShare a Scribd company logo
1 of 35
Huelva, 22nd April 2016
Juan Antonio Roy Couto
basicsbasics
#UHUMongoDB
Twitter Hashtag MongoDB Overview
2
Who am I?
Juan Antonio Roy Couto
❏ MongoDB Master
❏ Financial Software Developer
❏ Email: juanroycouto@gmail.com
❏ Twitter: @juanroycouto
❏ Linkedin: https://www.linkedin.com/in/juanroycouto
❏ Slideshare: slideshare.net/juanroycouto
❏ Personal site: http://www.juanroy.es
❏ Contributor at: http://www.mongodbspain.com
MongoDB Overview
3
❏ Basic Concepts
❏ Data Modelling
❏ Installation Types
❏ First Steps & CRUD
❏ Data Analytics With The Aggregation Framework
❏ Indexing
❏ Replica Set
❏ Sharded Cluster
❏ How To Scale Your App
❏ Python Driver Overview
Agenda MongoDB Overview
4
Basic Concepts - Concepts MongoDB Overview
❏ High Availability
❏ Data Safety
❏ Automatic Failover
❏ Scalability
5
❏ Faster development
❏ Real time analytics
❏ Better strategic decisions
❏ Reduce costs and time to
market
Basic Concepts - Products
https://www.mongodb.com/products/overview
MongoDB Overview
6
❏ Drivers
❏ Ops & Cloud Manager
❏ Compass
❏ Hadoop & Spark connector
❏ BI connector
❏ Pluggable Storage Engine API
Basic Concepts - Characteristics
http://www.mongodbspain.com/en/2014/08/17/mongodb-characteristics-future/
MongoDB Overview
7
❏ Open Source General Purpose NoSQL Database
❏ Document Oriented
❏ Non-Structured Data
❏ Schemaless
❏ Security (Authentication & Authorization)
❏ Document Validation, etc
Basic Concepts - SQL Schema
Design
MongoDB Overview
8
❏ Customer Key
❏ First Name
❏ Last Name
Tables
Customers
❏ Address Key
❏ Customer Key
❏ Street
❏ Number
❏ Location
Addresses
❏ Pet Key
❏ Customer Key
❏ Type
❏ Breed
❏ Name
Pets
Basic Concepts - MongoDB Schema
Design
MongoDB Overview
9
Customers Collection
❏ Street
❏ Number
❏ Location
Addresses
❏ Type
❏ Breed
❏ Name
Pets
Customers Info
❏ First Name
❏ Last Name
❏ Type
❏ Breed
❏ Name
Basic Concepts - JSON Document MongoDB Overview
10
> db.customers.findOne()
{
"_id" :
ObjectId("54131863041cd2e6181156ba"),
"first_name" : "Peter",
"last_name" : "Keil",
"address" : {
"street" : "C/Alcalá",
"number" : 123,
"location" : "Madrid",
},
"pets" : [
{
"type" : "Dog",
"breed" :
"Airedale Terrier",
"name" :
"Linda",
},
{
"type" : "Dog",
"breed" :
"Akita",
"name" :
"Bruto",
}
]
Data Modelling MongoDB Overview
11
1:1 Employee-Resume
❏ Access frequency
❏ Documents size
❏ Data atomicity
1:N City-Citizen
❏ Two linked collections
from N to 1
N:N Books-Authors
❏ Two collections linked via
array
1:Few Post-Comments
❏ One collection with
embedded data
Limits: 16MB/doc
Installation Types - Standalone MongoDB Overview
12
MongoDB
Client
DRIVER
Client
DRIVER
Client
DRIVER
Installation Types - Replica Set MongoDB Overview
13
SecondarySecondary
Primary
Client
DRIVER
Client
DRIVER
Client
DRIVER
Replica Set
Installation Types - Sharded Cluster MongoDB Overview
14
Replica Set
Secondary
Secondary
Primary
Client
DRIVER
Client
DRIVER
Client
DRIVER
Secondary
Secondary
Primary
Secondary
Secondary
Primary
Secondary
Secondary
Primary
mongos mongos mongos
config server
config server
config server
Shard 0 Shard 1 Shard 2 Shard N-1
❏ Find
❏ Insert
❏ Bulk inserts
❏ Massive Data Load
❏ Update
❏ Remove
First Steps & CRUD MongoDB Overview
15
Data Analytics with the
Aggregation Framework
MongoDB Overview
16
Data analytics Tools MongoDB Overview
17
❏ Internals
❏ Aggregation Framework
❏ Map Reduce
❏ Externals
❏ Spark
❏ Hadoop
❏ Tableau (BI)
❏ ...
MongoDB Overview
18
Indexing - Types
❏ _id
❏ Single
❏ Compound
❏ Multikey
❏ Full Text
❏ GeoSpatial
❏ Hashed
MongoDB Overview
19
Indexing - Properties
❏ Unique
❏ Sparse
❏ TTL
❏ Partial
MongoDB Overview
20
Indexing - Improving Your Queries
.explain()
❏ queryPlanner
❏ executionStats
❏ allPlansExecution
Replica Set
❏ High Availability
❏ Data Safety
❏ Automatic Node Recovery
❏ Read Preference
❏ Write Concern
Replica Set
Secondary
Secondary
Primary
MongoDB Overview
21
❏Scale out
❏Even data distribution across all of the
shards based on a shard key
❏A shard key range belongs to only one
shard
❏More efficient queries (performance)
Sharded Cluster
Cluster
Shard 0 Shard 2Shard 1
A-I J-Q R-Z
MongoDB Overview
22
Sharded Cluster - Config Servers
❏config database
❏Metadata:
❏Cluster shards list
❏Data per shard (chunk ranges)
❏...
❏Replica Set
MongoDB Overview
23
Replica Set
config server
config server
config server
❏Receives client requests and returns
results.
❏Reads the metadata and sends the
query to the necessary shard/shards.
❏Does not store data.
❏Keeps a cache version of the
metadata.
Sharded Cluster - mongos MongoDB Overview
24
Replica Set
DRIVER
Secondary
Secondary
Primary
Secondary
Secondary
Primary
mongos
config
server
config server
config server
Shard 0 Shard N-1
How To Scale Your App - Shard Key MongoDB Overview
25
❏Monotonically Increasing
❏Easy divisible❏Randomness❏Cardinality
How To Scale Your App
Sharding a Collection
MongoDB Overview
Shard 0 Shard 1 Shard 2 Shard 3
mongos
Client
Migrations
How To Scale Your App - Pre-Splitting MongoDB Overview
27
Useful for storing data directly
in the shards (massive
data loads).
Avoid bottlenecks.
MongoDB does not need to
split or migrate chunks.
After the split, the migration
must be finished before
data loading.
Cluster
Shard 0 Shard 2Shard 1
Chunk 1
Chunk 5
Chunk 3
Chunk 4
Chunk 2
How To Scale Your App
Tag-Aware Sharding
MongoDB Overview
28
Tags are used when you want to pin ranges to a specific shard.
shard0
EMEA
shard1
APAC
shard2
LATAM
shard3
NORAM
Python Driver - Overview MongoDB Overview
29
script1.py
import pymongo
from pymongo import MongoClient
connection = MongoClient(‘localhost’,27017)
db = connection.test
customers = db.customers
item = customers.findOne()
print item[‘firstname’]
$python script1.py
Python Driver - CRUD MongoDB Overview
30
PyMongo Server
Finding
find find
find_one findOne
Inserting
insert_one insert
insert_many bulk
Updating
update_one update
update_many update
replace_one update
Deleting
delete_one remove
delete_many remove
Python Driver - CRUD Examples MongoDB Overview
31
Insert
pedro = { ‘firstname’:‘Pedro’, ‘lastname’:‘García’ }
maria = { ‘firstname’:‘María’, ‘lastname’:‘Pérez’ }
doc = [ pedro, maria ]
customers.insert_many([doc])
Update
customers.update_one({‘_id’:customer_id},
{$set:{‘city’:‘Huelva’}})
Remove
customers.delete_one( { ‘_id’ : customer_id } )
Python Driver - Cursors And Exceptions MongoDB Overview
32
import pymongo
import sys
from pymongo import MongoClient
connection = MongoClient(‘localhost’,27017)
db = connection.test
customers = db.customers
query = { ‘firstname’ : ‘Juan’ }
projection = { ‘city’ : 1, ‘_id’ : 0 }
try:
cursor =
customers.find(query,projection)
exception Exception as e:
print ‘Unexpected error: ‘, type(e), e
for doc in cursor:
print doc[‘city’]
Resources MongoDB Basics
33
❏ Official MongoDB Documentation
❏ https://docs.mongodb.org/manual/
❏ Posts via MongoDB Spain
❏ http://www.mongodbspain.com/en/
❏ http://www.mongodbspain.com/es/
❏ Cheat Sheet
❏ http://www.mongodbspain.com/es/2014/03/23/mongodb-cheat-sheet-
quick-reference/
❏ The Little MongoDB Book
❏ http://openmymind.net/mongodb.pdf
Questions?
Questions? MongoDB Basics
34
Thank you for your attention!
MongoDB Workshop
Huelva, 22nd April 2016
Juan Antonio Roy Couto

More Related Content

What's hot

ManetoDB: Key/Value storage, BigData in Open Stack_Сергей Ковалев, Илья Свиридов
ManetoDB: Key/Value storage, BigData in Open Stack_Сергей Ковалев, Илья СвиридовManetoDB: Key/Value storage, BigData in Open Stack_Сергей Ковалев, Илья Свиридов
ManetoDB: Key/Value storage, BigData in Open Stack_Сергей Ковалев, Илья СвиридовGeeksLab Odessa
 
JDD 2016 - Michal Matloka - Small Intro To Big Data
JDD 2016 - Michal Matloka - Small Intro To Big DataJDD 2016 - Michal Matloka - Small Intro To Big Data
JDD 2016 - Michal Matloka - Small Intro To Big DataPROIDEA
 
Techniques used in RDF Data Publishing at Nature Publishing Group
Techniques used in RDF Data Publishing at Nature Publishing GroupTechniques used in RDF Data Publishing at Nature Publishing Group
Techniques used in RDF Data Publishing at Nature Publishing GroupTony Hammond
 
Tweaking perfomance on high-load projects_Думанский Дмитрий
Tweaking perfomance on high-load projects_Думанский ДмитрийTweaking perfomance on high-load projects_Думанский Дмитрий
Tweaking perfomance on high-load projects_Думанский ДмитрийGeeksLab Odessa
 
MongoDB - javascript for your data
MongoDB - javascript for your dataMongoDB - javascript for your data
MongoDB - javascript for your dataaaronheckmann
 
MongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big ComputeMongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big ComputeMongoDB
 
Security Monitoring for big Infrastructures without a Million Dollar budget
Security Monitoring for big Infrastructures without a Million Dollar budgetSecurity Monitoring for big Infrastructures without a Million Dollar budget
Security Monitoring for big Infrastructures without a Million Dollar budgetJuan Berner
 
RedisConf18 - Redis and Elasticsearch
RedisConf18 - Redis and ElasticsearchRedisConf18 - Redis and Elasticsearch
RedisConf18 - Redis and ElasticsearchRedis Labs
 
Agility and Scalability with MongoDB
Agility and Scalability with MongoDBAgility and Scalability with MongoDB
Agility and Scalability with MongoDBMongoDB
 
High Performance Applications with MongoDB
High Performance Applications with MongoDBHigh Performance Applications with MongoDB
High Performance Applications with MongoDBMongoDB
 
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DBMarch 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DBJosiah Carlson
 
Back to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQLBack to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQLMongoDB
 
Working with MongoDB as MySQL DBA
Working with MongoDB as MySQL DBAWorking with MongoDB as MySQL DBA
Working with MongoDB as MySQL DBAIgor Donchovski
 
Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...
Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...
Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...Hernan Costante
 
How Banks Manage Risk with MongoDB
How Banks Manage Risk with MongoDBHow Banks Manage Risk with MongoDB
How Banks Manage Risk with MongoDBMongoDB
 
MongoDB for Time Series Data Part 1: Setting the Stage for Sensor Management
MongoDB for Time Series Data Part 1: Setting the Stage for Sensor ManagementMongoDB for Time Series Data Part 1: Setting the Stage for Sensor Management
MongoDB for Time Series Data Part 1: Setting the Stage for Sensor ManagementMongoDB
 

What's hot (20)

ManetoDB: Key/Value storage, BigData in Open Stack_Сергей Ковалев, Илья Свиридов
ManetoDB: Key/Value storage, BigData in Open Stack_Сергей Ковалев, Илья СвиридовManetoDB: Key/Value storage, BigData in Open Stack_Сергей Ковалев, Илья Свиридов
ManetoDB: Key/Value storage, BigData in Open Stack_Сергей Ковалев, Илья Свиридов
 
JDD 2016 - Michal Matloka - Small Intro To Big Data
JDD 2016 - Michal Matloka - Small Intro To Big DataJDD 2016 - Michal Matloka - Small Intro To Big Data
JDD 2016 - Michal Matloka - Small Intro To Big Data
 
Techniques used in RDF Data Publishing at Nature Publishing Group
Techniques used in RDF Data Publishing at Nature Publishing GroupTechniques used in RDF Data Publishing at Nature Publishing Group
Techniques used in RDF Data Publishing at Nature Publishing Group
 
Tweaking perfomance on high-load projects_Думанский Дмитрий
Tweaking perfomance on high-load projects_Думанский ДмитрийTweaking perfomance on high-load projects_Думанский Дмитрий
Tweaking perfomance on high-load projects_Думанский Дмитрий
 
MongoDB - javascript for your data
MongoDB - javascript for your dataMongoDB - javascript for your data
MongoDB - javascript for your data
 
MongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big ComputeMongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big Compute
 
Security Monitoring for big Infrastructures without a Million Dollar budget
Security Monitoring for big Infrastructures without a Million Dollar budgetSecurity Monitoring for big Infrastructures without a Million Dollar budget
Security Monitoring for big Infrastructures without a Million Dollar budget
 
Demonstration
DemonstrationDemonstration
Demonstration
 
Mongodb (1)
Mongodb (1)Mongodb (1)
Mongodb (1)
 
RedisConf18 - Redis and Elasticsearch
RedisConf18 - Redis and ElasticsearchRedisConf18 - Redis and Elasticsearch
RedisConf18 - Redis and Elasticsearch
 
Agility and Scalability with MongoDB
Agility and Scalability with MongoDBAgility and Scalability with MongoDB
Agility and Scalability with MongoDB
 
High Performance Applications with MongoDB
High Performance Applications with MongoDBHigh Performance Applications with MongoDB
High Performance Applications with MongoDB
 
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DBMarch 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
March 29, 2016 Dr. Josiah Carlson talks about using Redis as a Time Series DB
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
 
Back to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQLBack to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQL
 
Working with MongoDB as MySQL DBA
Working with MongoDB as MySQL DBAWorking with MongoDB as MySQL DBA
Working with MongoDB as MySQL DBA
 
Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...
Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...
Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...
 
How Banks Manage Risk with MongoDB
How Banks Manage Risk with MongoDBHow Banks Manage Risk with MongoDB
How Banks Manage Risk with MongoDB
 
Mongodb
MongodbMongodb
Mongodb
 
MongoDB for Time Series Data Part 1: Setting the Stage for Sensor Management
MongoDB for Time Series Data Part 1: Setting the Stage for Sensor ManagementMongoDB for Time Series Data Part 1: Setting the Stage for Sensor Management
MongoDB for Time Series Data Part 1: Setting the Stage for Sensor Management
 

Similar to MongoDB Workshop Universidad de Huelva

Architecting Wide-ranging Analytical Solutions with MongoDB
Architecting Wide-ranging Analytical Solutions with MongoDBArchitecting Wide-ranging Analytical Solutions with MongoDB
Architecting Wide-ranging Analytical Solutions with MongoDBMatthew Kalan
 
An introduction to MongoDB by César Trigo #OpenExpoDay 2014
An introduction to MongoDB by César Trigo #OpenExpoDay 2014An introduction to MongoDB by César Trigo #OpenExpoDay 2014
An introduction to MongoDB by César Trigo #OpenExpoDay 2014OpenExpoES
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDBCésar Trigo
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialPHP Support
 
how_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxhow_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxsarah david
 
MongoDB NoSQL - Developer Guide
MongoDB NoSQL - Developer GuideMongoDB NoSQL - Developer Guide
MongoDB NoSQL - Developer GuideShiv K Sah
 
how_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfhow_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfsarah david
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBMarco Segato
 
MongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseMongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseFITC
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB
 
Mongo db transcript
Mongo db transcriptMongo db transcript
Mongo db transcriptfoliba
 
MongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB
 

Similar to MongoDB Workshop Universidad de Huelva (20)

MongoDB Basics Unileon
MongoDB Basics UnileonMongoDB Basics Unileon
MongoDB Basics Unileon
 
MongoDB FabLab León
MongoDB FabLab LeónMongoDB FabLab León
MongoDB FabLab León
 
Architecting Wide-ranging Analytical Solutions with MongoDB
Architecting Wide-ranging Analytical Solutions with MongoDBArchitecting Wide-ranging Analytical Solutions with MongoDB
Architecting Wide-ranging Analytical Solutions with MongoDB
 
An introduction to MongoDB by César Trigo #OpenExpoDay 2014
An introduction to MongoDB by César Trigo #OpenExpoDay 2014An introduction to MongoDB by César Trigo #OpenExpoDay 2014
An introduction to MongoDB by César Trigo #OpenExpoDay 2014
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js Tutorial
 
how_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxhow_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptx
 
Mongo db report
Mongo db reportMongo db report
Mongo db report
 
MongoDB NoSQL - Developer Guide
MongoDB NoSQL - Developer GuideMongoDB NoSQL - Developer Guide
MongoDB NoSQL - Developer Guide
 
New paradigms
New paradigmsNew paradigms
New paradigms
 
how_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfhow_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdf
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
 
Mongo db operations_v2
Mongo db operations_v2Mongo db operations_v2
Mongo db operations_v2
 
MongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseMongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL Database
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
Mongo db transcript
Mongo db transcriptMongo db transcript
Mongo db transcript
 
Mongodb
MongodbMongodb
Mongodb
 
Introduction to mongodb
Introduction to mongodbIntroduction to mongodb
Introduction to mongodb
 
MongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and Implications
 

Recently uploaded

April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 

Recently uploaded (20)

April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 

MongoDB Workshop Universidad de Huelva

  • 1. Huelva, 22nd April 2016 Juan Antonio Roy Couto basicsbasics
  • 3. Who am I? Juan Antonio Roy Couto ❏ MongoDB Master ❏ Financial Software Developer ❏ Email: juanroycouto@gmail.com ❏ Twitter: @juanroycouto ❏ Linkedin: https://www.linkedin.com/in/juanroycouto ❏ Slideshare: slideshare.net/juanroycouto ❏ Personal site: http://www.juanroy.es ❏ Contributor at: http://www.mongodbspain.com MongoDB Overview 3
  • 4. ❏ Basic Concepts ❏ Data Modelling ❏ Installation Types ❏ First Steps & CRUD ❏ Data Analytics With The Aggregation Framework ❏ Indexing ❏ Replica Set ❏ Sharded Cluster ❏ How To Scale Your App ❏ Python Driver Overview Agenda MongoDB Overview 4
  • 5. Basic Concepts - Concepts MongoDB Overview ❏ High Availability ❏ Data Safety ❏ Automatic Failover ❏ Scalability 5 ❏ Faster development ❏ Real time analytics ❏ Better strategic decisions ❏ Reduce costs and time to market
  • 6. Basic Concepts - Products https://www.mongodb.com/products/overview MongoDB Overview 6 ❏ Drivers ❏ Ops & Cloud Manager ❏ Compass ❏ Hadoop & Spark connector ❏ BI connector ❏ Pluggable Storage Engine API
  • 7. Basic Concepts - Characteristics http://www.mongodbspain.com/en/2014/08/17/mongodb-characteristics-future/ MongoDB Overview 7 ❏ Open Source General Purpose NoSQL Database ❏ Document Oriented ❏ Non-Structured Data ❏ Schemaless ❏ Security (Authentication & Authorization) ❏ Document Validation, etc
  • 8. Basic Concepts - SQL Schema Design MongoDB Overview 8 ❏ Customer Key ❏ First Name ❏ Last Name Tables Customers ❏ Address Key ❏ Customer Key ❏ Street ❏ Number ❏ Location Addresses ❏ Pet Key ❏ Customer Key ❏ Type ❏ Breed ❏ Name Pets
  • 9. Basic Concepts - MongoDB Schema Design MongoDB Overview 9 Customers Collection ❏ Street ❏ Number ❏ Location Addresses ❏ Type ❏ Breed ❏ Name Pets Customers Info ❏ First Name ❏ Last Name ❏ Type ❏ Breed ❏ Name
  • 10. Basic Concepts - JSON Document MongoDB Overview 10 > db.customers.findOne() { "_id" : ObjectId("54131863041cd2e6181156ba"), "first_name" : "Peter", "last_name" : "Keil", "address" : { "street" : "C/Alcalá", "number" : 123, "location" : "Madrid", }, "pets" : [ { "type" : "Dog", "breed" : "Airedale Terrier", "name" : "Linda", }, { "type" : "Dog", "breed" : "Akita", "name" : "Bruto", } ]
  • 11. Data Modelling MongoDB Overview 11 1:1 Employee-Resume ❏ Access frequency ❏ Documents size ❏ Data atomicity 1:N City-Citizen ❏ Two linked collections from N to 1 N:N Books-Authors ❏ Two collections linked via array 1:Few Post-Comments ❏ One collection with embedded data Limits: 16MB/doc
  • 12. Installation Types - Standalone MongoDB Overview 12 MongoDB Client DRIVER Client DRIVER Client DRIVER
  • 13. Installation Types - Replica Set MongoDB Overview 13 SecondarySecondary Primary Client DRIVER Client DRIVER Client DRIVER Replica Set
  • 14. Installation Types - Sharded Cluster MongoDB Overview 14 Replica Set Secondary Secondary Primary Client DRIVER Client DRIVER Client DRIVER Secondary Secondary Primary Secondary Secondary Primary Secondary Secondary Primary mongos mongos mongos config server config server config server Shard 0 Shard 1 Shard 2 Shard N-1
  • 15. ❏ Find ❏ Insert ❏ Bulk inserts ❏ Massive Data Load ❏ Update ❏ Remove First Steps & CRUD MongoDB Overview 15
  • 16. Data Analytics with the Aggregation Framework MongoDB Overview 16
  • 17. Data analytics Tools MongoDB Overview 17 ❏ Internals ❏ Aggregation Framework ❏ Map Reduce ❏ Externals ❏ Spark ❏ Hadoop ❏ Tableau (BI) ❏ ...
  • 18. MongoDB Overview 18 Indexing - Types ❏ _id ❏ Single ❏ Compound ❏ Multikey ❏ Full Text ❏ GeoSpatial ❏ Hashed
  • 19. MongoDB Overview 19 Indexing - Properties ❏ Unique ❏ Sparse ❏ TTL ❏ Partial
  • 20. MongoDB Overview 20 Indexing - Improving Your Queries .explain() ❏ queryPlanner ❏ executionStats ❏ allPlansExecution
  • 21. Replica Set ❏ High Availability ❏ Data Safety ❏ Automatic Node Recovery ❏ Read Preference ❏ Write Concern Replica Set Secondary Secondary Primary MongoDB Overview 21
  • 22. ❏Scale out ❏Even data distribution across all of the shards based on a shard key ❏A shard key range belongs to only one shard ❏More efficient queries (performance) Sharded Cluster Cluster Shard 0 Shard 2Shard 1 A-I J-Q R-Z MongoDB Overview 22
  • 23. Sharded Cluster - Config Servers ❏config database ❏Metadata: ❏Cluster shards list ❏Data per shard (chunk ranges) ❏... ❏Replica Set MongoDB Overview 23 Replica Set config server config server config server
  • 24. ❏Receives client requests and returns results. ❏Reads the metadata and sends the query to the necessary shard/shards. ❏Does not store data. ❏Keeps a cache version of the metadata. Sharded Cluster - mongos MongoDB Overview 24 Replica Set DRIVER Secondary Secondary Primary Secondary Secondary Primary mongos config server config server config server Shard 0 Shard N-1
  • 25. How To Scale Your App - Shard Key MongoDB Overview 25 ❏Monotonically Increasing ❏Easy divisible❏Randomness❏Cardinality
  • 26. How To Scale Your App Sharding a Collection MongoDB Overview Shard 0 Shard 1 Shard 2 Shard 3 mongos Client Migrations
  • 27. How To Scale Your App - Pre-Splitting MongoDB Overview 27 Useful for storing data directly in the shards (massive data loads). Avoid bottlenecks. MongoDB does not need to split or migrate chunks. After the split, the migration must be finished before data loading. Cluster Shard 0 Shard 2Shard 1 Chunk 1 Chunk 5 Chunk 3 Chunk 4 Chunk 2
  • 28. How To Scale Your App Tag-Aware Sharding MongoDB Overview 28 Tags are used when you want to pin ranges to a specific shard. shard0 EMEA shard1 APAC shard2 LATAM shard3 NORAM
  • 29. Python Driver - Overview MongoDB Overview 29 script1.py import pymongo from pymongo import MongoClient connection = MongoClient(‘localhost’,27017) db = connection.test customers = db.customers item = customers.findOne() print item[‘firstname’] $python script1.py
  • 30. Python Driver - CRUD MongoDB Overview 30 PyMongo Server Finding find find find_one findOne Inserting insert_one insert insert_many bulk Updating update_one update update_many update replace_one update Deleting delete_one remove delete_many remove
  • 31. Python Driver - CRUD Examples MongoDB Overview 31 Insert pedro = { ‘firstname’:‘Pedro’, ‘lastname’:‘García’ } maria = { ‘firstname’:‘María’, ‘lastname’:‘Pérez’ } doc = [ pedro, maria ] customers.insert_many([doc]) Update customers.update_one({‘_id’:customer_id}, {$set:{‘city’:‘Huelva’}}) Remove customers.delete_one( { ‘_id’ : customer_id } )
  • 32. Python Driver - Cursors And Exceptions MongoDB Overview 32 import pymongo import sys from pymongo import MongoClient connection = MongoClient(‘localhost’,27017) db = connection.test customers = db.customers query = { ‘firstname’ : ‘Juan’ } projection = { ‘city’ : 1, ‘_id’ : 0 } try: cursor = customers.find(query,projection) exception Exception as e: print ‘Unexpected error: ‘, type(e), e for doc in cursor: print doc[‘city’]
  • 33. Resources MongoDB Basics 33 ❏ Official MongoDB Documentation ❏ https://docs.mongodb.org/manual/ ❏ Posts via MongoDB Spain ❏ http://www.mongodbspain.com/en/ ❏ http://www.mongodbspain.com/es/ ❏ Cheat Sheet ❏ http://www.mongodbspain.com/es/2014/03/23/mongodb-cheat-sheet- quick-reference/ ❏ The Little MongoDB Book ❏ http://openmymind.net/mongodb.pdf
  • 35. Thank you for your attention! MongoDB Workshop Huelva, 22nd April 2016 Juan Antonio Roy Couto