SlideShare a Scribd company logo
1 of 20
Download to read offline
Introduction to

 MongoDB
       Raviteja Dodda
Co-Founder, Pipal Tech Ventures

 raviteja@pipaltechventures.com
Twitter, Facebook - @raviteja2007


                                    April 1st, 2012
The Great Divide




MongoDB - Sweet Spot: Easy, Flexible and Scalable
What is MongoDB ?
• Scalable High-Performance Open-source,
Document-orientated database.

• Built for Speed

• Rich Document based queries for Easy readability.

• Full Index Support for High Performance.

• Replication and Failover for High Availability.

• Auto Sharding for Easy Scalability.

• Map / Reduce for Aggregation.
Why 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.
What is MongoDB great for?
• RDBMS replacement for Web Applications.

• Semi-structured Content Management.

• Real-time Analytics & High-Speed Logging.

• Caching and High Scalability

   Web 2.0, Media, SAAS, Gaming
   HealthCare, Finance, Telecom, Government
Not great for?
 • Highly Transactional Applications.

 • Problems requiring SQL.

Some Companies using MongoDB in Production
Let’s Dive in !
When I say                                  Think

 Database                                 Database

• Made up of Multiple Collections.

• Created on-the-fly when referenced for the first time.
When I say                                  Think

Collection                                   Table

• Schema-less, and contains Documents.

• Indexable by one/more keys.

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

• Capped Collections: Fixed size, older records get dropped
after reaching the limit.
When I say                               Think

Document                             Record/Row

• Stored in a Collection.

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

• Supported Relationships – Embedded (or) References.

• Document storage in BSON (Binary form of JSON).
Understanding the Document Model.
var p = {
‘_id’: ‘3432’,
‘author’: DBRef(‘User’, 2),
‘title’: ‘Introduction to MongoDB’,
‘body’: ‘MongoDB is an open sources.. ‘,
‘timestamp’: Date(’01-04-12’),
‘tags’: [‘MongoDB’, ‘NoSQL’],
‘comments’: [{‘author’: DBRef(‘User’, 4),
                  ‘date’: Date(’02-04-12’),
                  ‘text’: ‘Did you see.. ‘,
                  ‘upvotes’: 7, … ]
}
> db.posts.save(p);
Secondary Indexes
Create Index on any field in the document
// 1 means ascending, -1 means descending
> db.posts.ensureIndex({‘author’: 1});

//Index Nested Documents
> db.posts.ensureIndex(‘comments.author’: 1);

// Index on tags
> db.posts.ensureIndex({‘tags’: 1});

// Geo-spatial Index
> db.posts.ensureIndex({‘author.location’: ‘2d’});
What about Queries? So Simple
// find posts which has ‘MongoDB’ tag.
> db.posts.find({tags: ‘MongoDB’});

// find posts by author’s comments.
> db.posts.find({‘comments.author’:
DBRef(‘User’,2)}).count();

// find posts written after 31st March.
> db.posts.find({‘timestamp’: {‘gte’: Date(’31-03-12’)}});

// find posts written by authors around [22, 42]
> db.posts.find({‘author.location’: {‘near’:[22, 42]});
 $gt, $lt, $gte, $lte, $ne, $all, $in, $nin, count, limit, skip, group, etc…
What about Updates? Atomic Operations makes it simple

db.posts.update({_id: ‘3432’},
{‘title’: ‘Introduction to MongoDB (updated)’,
‘text’: ‘Updated text’,
${addToSet: {‘tags’: ‘webinar’}});


  $set, $unset

 $push, $pull, $pop, $addToSet

 $inc, $decr, many more…



          Where are my joins and transactions? !!!
Some Cool features

• 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.
Deployment
 & Scaling
Replica Sets
Sharding
How do we use MongoDB at Pipal



Python                         MongoDB

           MongoEngine
       PyMongo based ORM – A Separate Topic !




Btw, Pipal is hiring at Bangalore
Backend Engineers, Frontend Engineers, System-Administrators
Send us your resume at careers@pipaltechventures.com
Questions?

            Next Steps: http://mongodb.org,
                  Twitter: @mongodb

                       Thank You 



Stay Hungry, Stay Foolish !!!
              - Steve Jobs

More Related Content

What's hot

What's hot (20)

Mongo db intro.pptx
Mongo db intro.pptxMongo db intro.pptx
Mongo db intro.pptx
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
 
Indexing with MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
introduction to NOSQL Database
introduction to NOSQL Databaseintroduction to NOSQL Database
introduction to NOSQL Database
 
Introduction to mongodb
Introduction to mongodbIntroduction to mongodb
Introduction to mongodb
 
NOSQL Databases types and Uses
NOSQL Databases types and UsesNOSQL Databases types and Uses
NOSQL Databases types and Uses
 
Mongo DB
Mongo DB Mongo DB
Mongo DB
 
Mongo DB Presentation
Mongo DB PresentationMongo DB Presentation
Mongo DB Presentation
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
 
NOSQL vs SQL
NOSQL vs SQLNOSQL vs SQL
NOSQL vs SQL
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
Data Modeling for MongoDB
Data Modeling for MongoDBData Modeling for MongoDB
Data Modeling for MongoDB
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptx
 
MongoDB at Scale
MongoDB at ScaleMongoDB at Scale
MongoDB at Scale
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
 
9. Document Oriented Databases
9. Document Oriented Databases9. Document Oriented Databases
9. Document Oriented Databases
 

Viewers also liked

Intro To MongoDB
Intro To MongoDBIntro To MongoDB
Intro To MongoDBAlex Sharp
 
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)MongoDB
 
MongoDB Java Development - MongoBoston 2010
MongoDB Java Development - MongoBoston 2010MongoDB Java Development - MongoBoston 2010
MongoDB Java Development - MongoBoston 2010Eliot Horowitz
 
Using MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkUsing MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkStefano Paluello
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverMongoDB
 
Кратко о MongoDB
Кратко о MongoDBКратко о MongoDB
Кратко о MongoDBGleb Lebedev
 
The Path to Truly Understanding your MongoDB Data
The Path to Truly Understanding your MongoDB DataThe Path to Truly Understanding your MongoDB Data
The Path to Truly Understanding your MongoDB DataMongoDB
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsJonas Bonér
 

Viewers also liked (11)

Intro To MongoDB
Intro To MongoDBIntro To MongoDB
Intro To MongoDB
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
 
MongoDB Java Development - MongoBoston 2010
MongoDB Java Development - MongoBoston 2010MongoDB Java Development - MongoBoston 2010
MongoDB Java Development - MongoBoston 2010
 
Using MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkUsing MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET Driver
 
MongoDB@addconf
MongoDB@addconfMongoDB@addconf
MongoDB@addconf
 
Mongodb
MongodbMongodb
Mongodb
 
Кратко о MongoDB
Кратко о MongoDBКратко о MongoDB
Кратко о MongoDB
 
The Path to Truly Understanding your MongoDB Data
The Path to Truly Understanding your MongoDB DataThe Path to Truly Understanding your MongoDB Data
The Path to Truly Understanding your MongoDB Data
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 

Similar to Introduction to MongoDB

MongoDB by Emroz sardar.
MongoDB by Emroz sardar.MongoDB by Emroz sardar.
MongoDB by Emroz sardar.Emroz Sardar
 
Mongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in BangaloreMongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in Bangalorerajkamaltibacademy
 
MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring dataJimmy Ray
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDBNorberto Leite
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCupWebGeek Philippines
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyNETWAYS
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharpSerdar Buyuktemiz
 
Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answersjeetendra mandal
 
Mongodb intro
Mongodb introMongodb intro
Mongodb introchristkv
 
Everything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptxEverything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptx75waytechnologies
 
When to Use MongoDB
When to Use MongoDBWhen to Use MongoDB
When to Use MongoDBMongoDB
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Consjohnrjenson
 
Mongodb open data day 2014
Mongodb open data day 2014Mongodb open data day 2014
Mongodb open data day 2014David Green
 

Similar to Introduction to MongoDB (20)

MongoDB by Emroz sardar.
MongoDB by Emroz sardar.MongoDB by Emroz sardar.
MongoDB by Emroz sardar.
 
Mongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in BangaloreMongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in Bangalore
 
MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring data
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongodb
MongodbMongodb
Mongodb
 
MongoDB.pptx
MongoDB.pptxMongoDB.pptx
MongoDB.pptx
 
10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
 
Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
Everything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptxEverything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptx
 
When to Use MongoDB
When to Use MongoDBWhen to Use MongoDB
When to Use MongoDB
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
 
Mongodb open data day 2014
Mongodb open data day 2014Mongodb open data day 2014
Mongodb open data day 2014
 
Introduction to Mongodb
Introduction to MongodbIntroduction to Mongodb
Introduction to Mongodb
 
Mongo db
Mongo dbMongo db
Mongo db
 

Recently uploaded

High-Level Synthesis for the Design of AI Chips
High-Level Synthesis for the Design of AI ChipsHigh-Level Synthesis for the Design of AI Chips
High-Level Synthesis for the Design of AI ChipsObject Automation
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
ict grade 12 lesson 2 sinhala medium notes pdf
ict grade 12 lesson 2 sinhala medium notes pdfict grade 12 lesson 2 sinhala medium notes pdf
ict grade 12 lesson 2 sinhala medium notes pdfruhisiya9
 
Plant tissue culture pharmacongosy-1 Semester 4
Plant tissue culture pharmacongosy-1 Semester 4Plant tissue culture pharmacongosy-1 Semester 4
Plant tissue culture pharmacongosy-1 Semester 4Nandakishor Deshmukh
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
Future Research Directions for Augmented Reality
Future Research Directions for Augmented RealityFuture Research Directions for Augmented Reality
Future Research Directions for Augmented RealityMark Billinghurst
 
RAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AIRAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AIUdaiappa Ramachandran
 
Things you didn't know you can use in your Salesforce
Things you didn't know you can use in your SalesforceThings you didn't know you can use in your Salesforce
Things you didn't know you can use in your SalesforceMartin Humpolec
 
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Monitoring Java Application Security with JDK Tools and JFR Events.pdfMonitoring Java Application Security with JDK Tools and JFR Events.pdf
Monitoring Java Application Security with JDK Tools and JFR Events.pdfAna-Maria Mihalceanu
 
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServicePicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServiceRenan Moreira de Oliveira
 
AI-based audio transcription solutions (IDP)
AI-based audio transcription solutions (IDP)AI-based audio transcription solutions (IDP)
AI-based audio transcription solutions (IDP)KapilVaidya4
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
IEEE Computer Society 2024 Technology Predictions Update
IEEE Computer Society 2024 Technology Predictions UpdateIEEE Computer Society 2024 Technology Predictions Update
IEEE Computer Society 2024 Technology Predictions UpdateHironori Washizaki
 
GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncObject Automation
 
Elevate Your Business with TECUNIQUE's Tailored Solutions
Elevate Your Business with TECUNIQUE's Tailored SolutionsElevate Your Business with TECUNIQUE's Tailored Solutions
Elevate Your Business with TECUNIQUE's Tailored SolutionsJaydeep Chhasatia
 
Reference Domain Ontologies and Large Medical Language Models.pptx
Reference Domain Ontologies and Large Medical Language Models.pptxReference Domain Ontologies and Large Medical Language Models.pptx
Reference Domain Ontologies and Large Medical Language Models.pptxChimezie Ogbuji
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataSafe Software
 
Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.francesco barbera
 
5 Considerations For Choosing The Best Gutter Guards
5 Considerations For Choosing The Best Gutter Guards5 Considerations For Choosing The Best Gutter Guards
5 Considerations For Choosing The Best Gutter GuardsCPR Gutter Protection
 

Recently uploaded (20)

High-Level Synthesis for the Design of AI Chips
High-Level Synthesis for the Design of AI ChipsHigh-Level Synthesis for the Design of AI Chips
High-Level Synthesis for the Design of AI Chips
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
ict grade 12 lesson 2 sinhala medium notes pdf
ict grade 12 lesson 2 sinhala medium notes pdfict grade 12 lesson 2 sinhala medium notes pdf
ict grade 12 lesson 2 sinhala medium notes pdf
 
Plant tissue culture pharmacongosy-1 Semester 4
Plant tissue culture pharmacongosy-1 Semester 4Plant tissue culture pharmacongosy-1 Semester 4
Plant tissue culture pharmacongosy-1 Semester 4
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
Future Research Directions for Augmented Reality
Future Research Directions for Augmented RealityFuture Research Directions for Augmented Reality
Future Research Directions for Augmented Reality
 
RAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AIRAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AI
 
Things you didn't know you can use in your Salesforce
Things you didn't know you can use in your SalesforceThings you didn't know you can use in your Salesforce
Things you didn't know you can use in your Salesforce
 
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Monitoring Java Application Security with JDK Tools and JFR Events.pdfMonitoring Java Application Security with JDK Tools and JFR Events.pdf
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
 
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServicePicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
 
AI-based audio transcription solutions (IDP)
AI-based audio transcription solutions (IDP)AI-based audio transcription solutions (IDP)
AI-based audio transcription solutions (IDP)
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
IEEE Computer Society 2024 Technology Predictions Update
IEEE Computer Society 2024 Technology Predictions UpdateIEEE Computer Society 2024 Technology Predictions Update
IEEE Computer Society 2024 Technology Predictions Update
 
GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation Inc
 
Elevate Your Business with TECUNIQUE's Tailored Solutions
Elevate Your Business with TECUNIQUE's Tailored SolutionsElevate Your Business with TECUNIQUE's Tailored Solutions
Elevate Your Business with TECUNIQUE's Tailored Solutions
 
Reference Domain Ontologies and Large Medical Language Models.pptx
Reference Domain Ontologies and Large Medical Language Models.pptxReference Domain Ontologies and Large Medical Language Models.pptx
Reference Domain Ontologies and Large Medical Language Models.pptx
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
 
Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.
 
5 Considerations For Choosing The Best Gutter Guards
5 Considerations For Choosing The Best Gutter Guards5 Considerations For Choosing The Best Gutter Guards
5 Considerations For Choosing The Best Gutter Guards
 

Introduction to MongoDB

  • 1. Introduction to MongoDB Raviteja Dodda Co-Founder, Pipal Tech Ventures raviteja@pipaltechventures.com Twitter, Facebook - @raviteja2007 April 1st, 2012
  • 2. The Great Divide MongoDB - Sweet Spot: Easy, Flexible and Scalable
  • 3. What is MongoDB ? • Scalable High-Performance Open-source, Document-orientated database. • Built for Speed • Rich Document based queries for Easy readability. • Full Index Support for High Performance. • Replication and Failover for High Availability. • Auto Sharding for Easy Scalability. • Map / Reduce for Aggregation.
  • 4. Why 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.
  • 5. What is MongoDB great for? • RDBMS replacement for Web Applications. • Semi-structured Content Management. • Real-time Analytics & High-Speed Logging. • Caching and High Scalability Web 2.0, Media, SAAS, Gaming HealthCare, Finance, Telecom, Government
  • 6. Not great for? • Highly Transactional Applications. • Problems requiring SQL. Some Companies using MongoDB in Production
  • 8. When I say Think Database Database • Made up of Multiple Collections. • Created on-the-fly when referenced for the first time.
  • 9. When I say Think Collection Table • Schema-less, and contains Documents. • Indexable by one/more keys. • Created on-the-fly when referenced for the first time. • Capped Collections: Fixed size, older records get dropped after reaching the limit.
  • 10. When I say Think Document Record/Row • Stored in a Collection. • Can have _id key – works like Primary keys in MySQL. • Supported Relationships – Embedded (or) References. • Document storage in BSON (Binary form of JSON).
  • 11. Understanding the Document Model. var p = { ‘_id’: ‘3432’, ‘author’: DBRef(‘User’, 2), ‘title’: ‘Introduction to MongoDB’, ‘body’: ‘MongoDB is an open sources.. ‘, ‘timestamp’: Date(’01-04-12’), ‘tags’: [‘MongoDB’, ‘NoSQL’], ‘comments’: [{‘author’: DBRef(‘User’, 4), ‘date’: Date(’02-04-12’), ‘text’: ‘Did you see.. ‘, ‘upvotes’: 7, … ] } > db.posts.save(p);
  • 12. Secondary Indexes Create Index on any field in the document // 1 means ascending, -1 means descending > db.posts.ensureIndex({‘author’: 1}); //Index Nested Documents > db.posts.ensureIndex(‘comments.author’: 1); // Index on tags > db.posts.ensureIndex({‘tags’: 1}); // Geo-spatial Index > db.posts.ensureIndex({‘author.location’: ‘2d’});
  • 13. What about Queries? So Simple // find posts which has ‘MongoDB’ tag. > db.posts.find({tags: ‘MongoDB’}); // find posts by author’s comments. > db.posts.find({‘comments.author’: DBRef(‘User’,2)}).count(); // find posts written after 31st March. > db.posts.find({‘timestamp’: {‘gte’: Date(’31-03-12’)}}); // find posts written by authors around [22, 42] > db.posts.find({‘author.location’: {‘near’:[22, 42]}); $gt, $lt, $gte, $lte, $ne, $all, $in, $nin, count, limit, skip, group, etc…
  • 14. What about Updates? Atomic Operations makes it simple db.posts.update({_id: ‘3432’}, {‘title’: ‘Introduction to MongoDB (updated)’, ‘text’: ‘Updated text’, ${addToSet: {‘tags’: ‘webinar’}}); $set, $unset $push, $pull, $pop, $addToSet $inc, $decr, many more… Where are my joins and transactions? !!!
  • 15. Some Cool features • 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.
  • 19. How do we use MongoDB at Pipal Python MongoDB MongoEngine PyMongo based ORM – A Separate Topic ! Btw, Pipal is hiring at Bangalore Backend Engineers, Frontend Engineers, System-Administrators Send us your resume at careers@pipaltechventures.com
  • 20. Questions? Next Steps: http://mongodb.org, Twitter: @mongodb Thank You  Stay Hungry, Stay Foolish !!! - Steve Jobs