introduction to mongo db

44
Rohit Kumar [email protected] Manish Kapoor [email protected]

Upload: rohit-bishnoi

Post on 14-Apr-2017

482 views

Category:

Technology


1 download

TRANSCRIPT

Page 2: Introduction to mongo db

1.2.3.4.

Page 3: Introduction to mongo db

Page 4: Introduction to mongo db
Page 5: Introduction to mongo db

• 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.

Page 6: Introduction to mongo db
Page 7: Introduction to mongo db

••

Page 8: Introduction to mongo db
Page 9: Introduction to mongo db

SQL MongoDB

Table Collection

Row JSON Document

Page 10: Introduction to mongo db

Page 11: Introduction to mongo db

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

Page 12: Introduction to mongo db

Operations in MongoDB(cntd..)

db.issue.insert({

"_id" : 1,

"description" : "Your code does not work.",

"priority" : "HIGH"

});

Page 13: Introduction to mongo db

Operations in MongoDB(cntd..)

db.issue.insert(

{

"description" : "Your code does not work.",

"screenshot" : {

"url":"www.someurl.com",

"description":"manish's code doesnt work"

}

});

Page 14: Introduction to mongo db

Operations in MongoDB(cntd..)

db.issue.insert({

"description" : "Your code does not work",

"assignmentInfo" : [

{

"assignedTo" : "Manish",

"assignedBy" : "Raj"

},

{

"assignedTo" : "Vishal",

"assignedBy" : "Manish"

}

]

})

Page 15: Introduction to mongo db
Page 16: Introduction to mongo db

Page 18: Introduction to mongo db

••

Page 19: Introduction to mongo db

db.student.find({})

db.student.find({name: ’Raj’})

db.student.find({name: {$in: ['Raj','Tim']}})

Operations in MongoDB(cntd..)

Page 20: Introduction to mongo db

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({})

Page 21: Introduction to mongo db

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”)

Page 22: Introduction to mongo db

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})

Page 23: Introduction to mongo db

Operations in MongoDB(cntd..)

Page 25: Introduction to mongo db

•••

••

Page 26: Introduction to mongo db

Operations in MongoDB(cntd..)

db.student.count({"name":"Pulkit"})

Page 27: Introduction to mongo db

Operations in MongoDB(cntd..)

Page 28: Introduction to mongo db

Operations in MongoDB(cntd..)

Page 29: Introduction to mongo db

Operations in MongoDB(cntd..)

Page 30: Introduction to mongo db

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})

Page 32: Introduction to mongo db

1.

2.

3.

Page 33: Introduction to mongo db

Operations in MongoDB(cntd..)

db.student.remove({age:{$gt: 50}})

db.student.remove({})

Page 34: Introduction to mongo db

Operations in MongoDB(cntd..)

Page 35: Introduction to mongo db
Page 36: Introduction to mongo db

● 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.

Page 37: Introduction to mongo db
Page 38: Introduction to mongo db

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.

Page 39: Introduction to mongo db

•••••

Page 40: Introduction to mongo db
Page 41: Introduction to mongo db
Page 43: Introduction to mongo db
Page 44: Introduction to mongo db

••••

•••••