Rohit Kumar
rohit.kumar@tothenew.com
Manish Kapoor
manish.kapoor@tothenew.com
1.
2.
3.
4.
•
•
•
•
•
•
• Not Only SQL
• Schema less
• Support for nested data
• Non transactional
• Support for huge amount of data
• High availability (even while updations)
• Easy implementation of distributed architecture
• Examples: MongoDB, Cassandra, CouchBase,
Redis, Neo4J, HDFS etc.
•
•
•
•
•
•
SQL MongoDB
Table Collection
Row JSON Document
•
•
Operations in MongoDB
MongoDB Console mongo
List existing databases show dbs
Use a database ‘test’ use test
List collections in db: show collections /
show tables
Operations in MongoDB(cntd..)
db.issue.insert({
"_id" : 1,
"description" : "Your code does not work.",
"priority" : "HIGH"
});
Operations in MongoDB(cntd..)
db.issue.insert(
{
"description" : "Your code does not work.",
"screenshot" : {
"url":"www.someurl.com",
"description":"manish's code doesnt work"
}
});
Operations in MongoDB(cntd..)
db.issue.insert({
"description" : "Your code does not work",
"assignmentInfo" : [
{
"assignedTo" : "Manish",
"assignedBy" : "Raj"
},
{
"assignedTo" : "Vishal",
"assignedBy" : "Manish"
}
]
})
•
•
•
•
•
•
db.student.find({})
db.student.find({name: ’Raj’})
db.student.find({name: {$in: ['Raj','Tim']}})
Operations in MongoDB(cntd..)
Operations in MongoDB(cntd..)
db.student.find({age:{$gt:40}})
db.student.find({name: {$exists: "true"}})
select one student:(db.student.findOne
(criteria))
db.student.findOne({})
Operations in MongoDB(cntd..)
db.student.find().sort({_id:-1})
db.student.find().skip(2).limit(3)
Distinct:
Find all distinct cities:
db.student.distinct(“city”)
Operations in MongoDB(cntd..)
db.student.find({age:40},{name:1})
Select all fields except name where age = 40
db.student.find({age:40},{name:0})
What should the following query get?
db.student.find({age:40},{name:0, age:1})
Operations in MongoDB(cntd..)
•
•
•
•
•
•
•
Operations in MongoDB(cntd..)
db.student.count({"name":"Pulkit"})
Operations in MongoDB(cntd..)
Operations in MongoDB(cntd..)
Operations in MongoDB(cntd..)
Operations in MongoDB(cntd..)
db.student.update({age:{$gt: 20}}, {$set:{age:
30}},{multi:true})
db.student.update({age:{$gt: 20}}, {$set:{age:
30}},{upsert:true})
1.
2.
3.
Operations in MongoDB(cntd..)
db.student.remove({age:{$gt: 50}})
db.student.remove({})
Operations in MongoDB(cntd..)
● The Product: Thoughtbuzz is aimed at providing social media
analytics across all popular platforms.
● The Challenge: Pull humongous volumes of data from Social
Platforms using platform specific APIs and provide harmonious
analytics that look uniform across all Platforms.
How MongoDB helped us?
● We were able to put heterogeneous data coming from different
sources (Facebook and Twitter) into one collection.
● This collection helped us in providing various data with high
performance as their were no joins required for these queries.
● We saved writing duplicate code for performing similar
operations on multiple collections by using one single
homogeneous collection.
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

Introduction to mongo db