Introducción

Goals

asd

Introduction

Mongo Shell / CRUD

Schema Design

Indexing

Replication

Sharding

Analytics

Monitoring

Backup and Recovery

Additional Topics







Introduction







http://www.mongodb.org/about/introduction/






What is
MongoDB?

MongoDB is...




NoSQL

Document-Oriented Database

Multi-platform

and Open-source






Why was 
MongoDB built?

Big Data

Cloud Computing

Key Features




Flexibility
High Perfomance
High Availability
Scalable
Power
Easy to use


Hands On



  • Download 
  • Install
  • Connect
  • Shutdown
  • Mongo shell
  • Import data

"Momentum"




http://www.10gen.com/leading-nosql-database

http://www.google.com/trends/

http://www.indeed.com/jobtrends





Mongo Shell
CRUD





http://docs.mongodb.org/manual/mongo/
http://docs.mongodb.org/manual/crud/

You Know JavaScript?




for (i=0; i < 5; i++) {    print("hello from the mongo shell");}

???


> use <dbname>
> db.stats() 
> db.stats 
> db. // press TAB

Relational Databases


Document Oriented


Terminology



Database == Database

Table == Collection

Row = Document

Column == Attribute

JSON


   "name" : "Michel",   "registered" : true,   languages : [ "c#", "python", "ruby" ],
"address" : {  "city" : "Londrina", "state" : "PR" "country" : "Brasil" }, created_on : new Date()}

BSON




http://bsonspec.org/

Hands On



  • Insert
  • Query 
  • Projection
  • Cursor
  • Update
  • Remove 






Schema Design







http://docs.mongodb.org/manual/data-modeling/





"Store your data the way your application wants to see it"

Keep in mind



16mb per document
One to One?
One to Many?
Many to Many?

http://www.10gen.com/presentations/schema-design-6

Hands On



  • Ecommerce Design






Indexing







http://docs.mongodb.org/manual/core/indexes/




MongoDB 

is very FAST

But...

Index Types



_id Index

Secondary Index

Compound Index

Multikey Index

Geospatial Index

Hands On



  • explain()
  • Create index
    • sparse
    • unique
    • dropDups
    • background
    • '2d'






Replication







http://docs.mongodb.org/manual/replication/

High Availability



Redundancy
Failover
Read Scalability 















Hands On



  • Create Replica Set Cluster






Sharding







http://docs.mongodb.org/manual/sharding/

Scalability



No joins

No transactions

Horizontal Scalability



Hands On



  • Create Shard Cluster






Analitycs







http://docs.mongodb.org/manual/aggregation/

Aggregation

Framework


db.products.aggregate([
    {$group:
     {
	 _id: {
	     "maker":"$manufacturer"
	 },
	 max_price:{$max:"$price"}
     }
    }
]) 

Hands On



  • $match
  • $group
  • $project
  • $unwind
  • $avg
  • $sum
  • $sort
  • $limit






Monitoring







http://docs.mongodb.org/manual/administration/monitoring/

MMS

MongoDB Monitoring Services (10gen)

https://mms.10gen.com/

MMS

MongoDB Monitoring Services (10gen)


Benchmark





http://www.mongodb.org/about/contributors/js-benchmarking-harness/

Hands On



  • mongostat
  • mongotop
  • profilling






Backup and

Recovery




http://docs.mongodb.org/manual/core/backups/

Scenario 1

Single Server / Replica Set


Mongo / Mongo
Copy data manually
mongodump
mongorestore

MongoDB / Other Sources
mongoimport
mongoexport

Scenario 2

Sharding

MongoDB Backup Service (10gen)
http://www.10gen.com/products/mongodb-backup-service


Hands On



  • Dump
  • Restore
  • Import data (csv)






Additional Topics

Security


http://docs.mongodb.org/manual/security/


MongoDB SSL
MongoDB Gazzang
Authentication (Basic, Kerberos)
Roles

GridFS


http://docs.mongodb.org/manual/core/gridfs/


File Storage
Photos, Videos, Documents, etc

case:
http://www.shutterfly.com/

Drivers


http://docs.mongodb.org/ecosystem/drivers/


C#
C++
Java
Ruby
Python
Node.js
Erlang
Pearl

Hands On



  • C# and MongoDB
  • Python and MongoDB
Made with Slides.com