MongoDB is a free and open-source document-oriented NoSQL database created by Dwight Merriman, Eliot Horowitz and Kevin Ryan in 2007. It uses a schema-less structure that stores data in flexible, JSON-like documents, allowing for easy scaling and fast querying. Key features include replication for high availability, auto-sharding for horizontal scaling, and aggregation capabilities for complex queries. Common use cases include storing high volumes of unstructured or semi-structured data like blog posts, user comments, and digital content.
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
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> } )
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