際際滷

際際滷Share a Scribd company logo
Presented by Chamodi Adikaram (179333J)
content
 introduction
 cap theorem
 terminology
 structure
 key features
 crud operations
 best use cases
introduction
 mongoDB was founded in 2007 by Dwight
Merriman, Eliot Horowitz and Kevin Ryan (10gen)
 mongo comes from the term humongous.
 it is a free and open-source cross-platform
document-oriented NoSQL database program
cap theorem
availability
consistency partition tolerance
ca
cp
ap
cap theorem cntd
consistency:
 all replicas contain the same version of the data
partition tolerance:
 multiple entry points
 system remains operational on system split
 single master architecture to have consistency over availability
terminology
RDBMS mongoDB
database database
table collection
index index
row document
column field
join embedding & reference & $lookup
structure
structure
 documents in BSON (binary JSON): JSON like structure
key features
1. schema less
 application tracks the schema and mapping
 you can have different fields in every document
 no Data Definition Language
 keys are a basic data type but in reality stored as
strings
 document Identifiers (_id) will be created for each
document, field name reserved by system
 results in lot of flexibility
key features cntd
2. replication sets
 single master architecture
 maintaining backup copies of your
database instance
 secondaries can elect a new primary
within seconds if your primary goes
down
key features cntd
3. auto- sharding
 for big data
 distributes a single logical database
system across a cluster of machines
 ranges of some indexed value you
specify are assigned to different
replica sets
 can be turned on off per collection
 facilitates built in horizontal scaling
key features cntd
4. querying
 mongo shell
 you can write scripts for the mongo shell in
javascript that manipulate data in mongoDB
or perform administrative operation
 alternative to shell robomongo
key features cntd
5. fast in-place updates
 the database does not have to allocate and write a full new
copy of the object
 this can be highly performant for frequent update use cases
 mongoDB disk writes are lazy
key features cntd
6. aggregated functionality
 provides SQL-like aggregation
functionality
 expressions produce output documents
based on calculations performed on
input documents
 db.parts.aggregate ( {$group : {_id:
type, totalquantity : {$sum:quanity}} })
key features cntd
7. map/reduce functionality
 can perform map reduce operations without hadoop
 file system: gridFS
 performs complex aggregator functions given a collection of keys, value
pairs
 db.collection.mapReduce( <mapfunction>, <reducefunction>, { out:
<collection>, query: <document>, sort: <document>, limit: <number>,
finalize: <function>, scope: <document>, jsMode: <boolean>, verbose:
<boolean> } )
crud operations
 create
db.restaurants.insert({borough : 'Colombo',cuisine : 'Chinese',name:
'Fab',restaurant_id : '41704627'});
 read
db.restaurants.find({cuisine : 'Chinese'});
 update
db.restaurants.update({restaurant_id : '41704627'},{$set:
{name:'Fabulous'}});
 delete
db.restaurants.remove({restaurant_id : '41704627'});
best use cases
best use cases cntd
 suitable for high volume and scaling data such as:
 blog posts
 comments
 digital content management
 not suitable for highly transactional, business intelligence related
instances
Q&A
Thank you!

More Related Content

An Introduction to MongoDB

  • 1. Presented by Chamodi Adikaram (179333J)
  • 2. content introduction cap theorem terminology structure key features crud operations best use cases
  • 3. introduction mongoDB was founded in 2007 by Dwight Merriman, Eliot Horowitz and Kevin Ryan (10gen) mongo comes from the term humongous. it is a free and open-source cross-platform document-oriented NoSQL database program
  • 5. cap theorem cntd consistency: all replicas contain the same version of the data partition tolerance: multiple entry points system remains operational on system split single master architecture to have consistency over availability
  • 6. terminology RDBMS mongoDB database database table collection index index row document column field join embedding & reference & $lookup
  • 8. structure documents in BSON (binary JSON): JSON like structure
  • 9. key features 1. schema less application tracks the schema and mapping you can have different fields in every document no Data Definition Language keys are a basic data type but in reality stored as strings document Identifiers (_id) will be created for each document, field name reserved by system results in lot of flexibility
  • 10. key features cntd 2. replication sets single master architecture maintaining backup copies of your database instance secondaries can elect a new primary within seconds if your primary goes down
  • 11. key features cntd 3. auto- sharding for big data distributes a single logical database system across a cluster of machines ranges of some indexed value you specify are assigned to different replica sets can be turned on off per collection facilitates built in horizontal scaling
  • 12. key features cntd 4. querying mongo shell you can write scripts for the mongo shell in javascript that manipulate data in mongoDB or perform administrative operation alternative to shell robomongo
  • 13. key features cntd 5. fast in-place updates the database does not have to allocate and write a full new copy of the object this can be highly performant for frequent update use cases mongoDB disk writes are lazy
  • 14. key features cntd 6. aggregated functionality provides SQL-like aggregation functionality expressions produce output documents based on calculations performed on input documents db.parts.aggregate ( {$group : {_id: type, totalquantity : {$sum:quanity}} })
  • 15. key features cntd 7. map/reduce functionality can perform map reduce operations without hadoop file system: gridFS performs complex aggregator functions given a collection of keys, value pairs db.collection.mapReduce( <mapfunction>, <reducefunction>, { out: <collection>, query: <document>, sort: <document>, limit: <number>, finalize: <function>, scope: <document>, jsMode: <boolean>, verbose: <boolean> } )
  • 16. crud operations create db.restaurants.insert({borough : 'Colombo',cuisine : 'Chinese',name: 'Fab',restaurant_id : '41704627'}); read db.restaurants.find({cuisine : 'Chinese'}); update db.restaurants.update({restaurant_id : '41704627'},{$set: {name:'Fabulous'}}); delete db.restaurants.remove({restaurant_id : '41704627'});
  • 18. best use cases cntd suitable for high volume and scaling data such as: blog posts comments digital content management not suitable for highly transactional, business intelligence related instances