SlideShare uma empresa Scribd logo
1 de 20
MongoDB
Introduction to
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 !
Database
When I say
Database
Think
• Made up of Multiple Collections.
• Created on-the-fly when referenced for the first time.
Collection
When I say
Table
Think
• 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.
Document
When I say
Record/Row
Think
• 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).
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);
Understanding the Document Model.
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’});
Secondary Indexes
// 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]});
What about Queries? So Simple
$gt, $lt, $gte, $lte, $ne, $all, $in, $nin, count, limit, skip, group, etc…
db.posts.update({_id: ‘3432’},
{‘title’: ‘Introduction to MongoDB (updated)’,
‘text’: ‘Updated text’,
${addToSet: {‘tags’: ‘webinar’}});
What about Updates? Atomic Operations makes it simple
$set, $unset
Where are my joins and transactions? !!!
$push, $pull, $pop, $addToSet
$inc, $decr, many more…
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

Mais conteúdo relacionado

Semelhante a mongodb-120401144140-phpapp01 claud camputing

MongoDB_Sharan_Prakash_Babu
MongoDB_Sharan_Prakash_BabuMongoDB_Sharan_Prakash_Babu
MongoDB_Sharan_Prakash_Babu
Sharan
 

Semelhante a mongodb-120401144140-phpapp01 claud camputing (20)

Elasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparisonElasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparison
 
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 presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
 
Webinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB AppWebinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB App
 
A Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - HabilelabsA Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - Habilelabs
 
MongoDB
MongoDBMongoDB
MongoDB
 
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 Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorial
 
Introduction about Mongo DB for Beginners
Introduction about Mongo DB for Beginners Introduction about Mongo DB for Beginners
Introduction about Mongo DB for Beginners
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB NoSQL database a deep dive -MyWhitePaper
MongoDB  NoSQL database a deep dive -MyWhitePaperMongoDB  NoSQL database a deep dive -MyWhitePaper
MongoDB NoSQL database a deep dive -MyWhitePaper
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
Webinar: Live Data Visualisation with Tableau and MongoDB
Webinar: Live Data Visualisation with Tableau and MongoDBWebinar: Live Data Visualisation with Tableau and MongoDB
Webinar: Live Data Visualisation with Tableau and MongoDB
 
Introduction to Mongodb
Introduction to MongodbIntroduction to Mongodb
Introduction to Mongodb
 
05 darwino db
05   darwino db05   darwino db
05 darwino db
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Mongo db
Mongo dbMongo db
Mongo db
 
MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring data
 
MongoDB_Sharan_Prakash_Babu
MongoDB_Sharan_Prakash_BabuMongoDB_Sharan_Prakash_Babu
MongoDB_Sharan_Prakash_Babu
 

Último

The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
Krashi Coaching
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 

Último (20)

The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 

mongodb-120401144140-phpapp01 claud camputing

  • 1. MongoDB Introduction to 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. Database When I say Database Think • Made up of Multiple Collections. • Created on-the-fly when referenced for the first time.
  • 9. Collection When I say Table Think • 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. Document When I say Record/Row Think • 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. 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); Understanding the Document Model.
  • 12. 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’}); Secondary Indexes
  • 13. // 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]}); What about Queries? So Simple $gt, $lt, $gte, $lte, $ne, $all, $in, $nin, count, limit, skip, group, etc…
  • 14. db.posts.update({_id: ‘3432’}, {‘title’: ‘Introduction to MongoDB (updated)’, ‘text’: ‘Updated text’, ${addToSet: {‘tags’: ‘webinar’}}); What about Updates? Atomic Operations makes it simple $set, $unset Where are my joins and transactions? !!! $push, $pull, $pop, $addToSet $inc, $decr, many more…
  • 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