Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
MongoDB
1. MongoDB
By
Rony Abraham Gregory
Model Engineering College
2. What is MongoDB?
• Humongous (huge + monstrous)
• Document Database
• Schema free
• C++
• Open Source
3. What is MongoDB?
• GNU AGPL v3.0 Licence
• OSX, Linux, Windows, Solaris | 32
bit, 64 bit
• Development and Support by 10gen
and was first released in February 2009
• NoSQL!
5. Relational Databases
• ACID (Atomicity Consistency Isolation
and Durability)
• SQL
• MySQL, PostgreSQL, Oracle, etc.
6. Key-value stores
• “One key, one value, no duplicates and
very fast”
• It’s a Hash!
• The value is a binary object aka “blob” –
the DB doesn’t understand it and
doesn’t want to understand it.
• Amazon Dynamo, MemcacheDB, etc.
8. Document databases
• Key-value stores, but the value is
(usually) structured and “understood”
by the DB.
• Querying data is possible (by means
other than just a key).
• Amazon
SimpleDB, CouchDB, MongoDB, Riak, e
tc.
10. Why NoSQL?
• Schema-free
• Massive data stores
• Scalability
• Some services simpler to implement
than using RDBMS
• Great fit for many Web 2.0 applications
11. Why NOT NoSQL?
• RDBMSes and its tools are mature
• NoSQL implementations are often in
their “alpha” state
• Data consistency, transactions
• “Don’t scale until you need it”
12. RDBMS vs NoSQL
• Strong consistency vs Eventual
consistency
• Big dataset vs HUGE dataset
• Scaling is possible vs Scaling is easy
• Good availability vs Very high
availability
13. RDBMS vs NoSQL
• Strong consistency vs Eventual
consistency
• Big dataset vs HUGE dataset
• Scaling is possible vs Scaling is easy
• Good availability vs Very high
availability
14. RDBMS vs NoSQL
• Strong consistency vs Eventual
consistency
• Big dataset vs HUGE dataset
• Scaling is possible vs Scaling is easy
• Good availability vs Very high
availability
16. Features
• Documents are stored in BSON (JSON)
• BSON is a Binary serialization of JSON-
like objects
• This is extremely powerful, because it
means mongoDB understands JSON
natively
• Any valid JSON can be easily imported
and queried
17. Features
• Schema-less; very flexible
• Auto-sharding (alpha)
• Makes for easy horizontal; scaling
• Map/Reduce
19. Features: Querying
• Rich, JavaScript based query syntax
• Allows us to do deep, nested queries
db.order.find( {shipping: { carrier:”usps” }} );
shipping is an embedded document
(object)
21. Concepts: Document-Oriented
• Think of “documents” as
objects/database records
• Documents are basically just JSON in
binary
• Ability to store information all together
24. Concepts: Cursors
• Queries return “cursors” instead of
collections
• A cursor allows you to iterate through
the result set
• A big reason for this is performance
• Much more efficient than loading all
objects into memory
30. Basic Operations: Indexing
• Its usually a good idea to index
collections
• How and which columns depend on
what is to be done
db.test.ensureIndex({hello:I})
32. References
• MongoDB home at http://www.mongodb.org
• MongoDB - The Definitive Guide by Kristina
Chodorow and Dirolf
• NoSQL Paper at
http://wiki.hsr.ch/Datenbanken/files/Weber_NoSQL_
Paper.pdf
• Why MongoDB is awesome at
http://www.slideshare.net/jnunemaker/why-
mongodb-is-awesome
• MongoDB wiki at
http://en.wikipedia.org/wiki/MongoDB