Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro to MongoDB

Intro to MongoDB

Introduction to MongoDB


May 17, 2012

More Decks by 20spokes

Other Decks in Programming


  1. What you will hear What is NoSQL Available NoSQL Databases

    Intro to MongoDB Thursday, May 17, 12
  2. Fancy Answer NoSQL is a class of database management system

    identified by its non-adherence to the widely-use relational database management system Thursday, May 17, 12
  3. Does not use SQL as its query language May not

    give full ACID guarantees Distributed architecture Typically optimized for reading and writing operations Thursday, May 17, 12
  4. Traditional Scaling Bigger is better! (or so they thought) Increase

    the size and power of the server Thursday, May 17, 12
  5. Scaling with NoSql Scale horizontally! Distribute across multiple servers More

    economical using lower-cost servers Thursday, May 17, 12
  6. NoSQl is Still Young Does not reduce administration (at least

    not yet) Lack of expertise Lack of projects expanding on NoSQL Thursday, May 17, 12
  7. NoSQL out in the Wild Analytics - takes advantage of

    read/write optimizations Logging Large Scale Projects Thursday, May 17, 12
  8. What is MongoDB Document Oriented Storage Replication & Auto-Sharding Document-based

    queries similar to SQL Atomic Updates Map/Reduce Thursday, May 17, 12
  9. Document Oriented No schemas!! No joins for high performance and

    scalability embed documents JSON-Style storage Thursday, May 17, 12
  10. High Performance Stores a lot of data in memory Embedding

    documents increase read and writes Allows indexing Thursday, May 17, 12
  11. Availability and Scalability Replicated servers with automatic master failover Auto-sharing

    across servers Consistent reads distributed over replicated servers Thursday, May 17, 12
  12. Atomic Modifers In place updating documents Does not replace entire

    document Ideally suited for write heavy applications Thursday, May 17, 12
  13. Storing data Data is grouped by collections Collection contains documents

    of key-value pairs Values can be rich including arrays and documents Stored as BSON - Binary Serialized Document Notation Thursday, May 17, 12
  14. Querying Javascript console allows for functions Returns a cursor -

    lazy load of results Queries expressed as JSON Documents auto-assigned ObjectId Thursday, May 17, 12
  15. Embed vs Referenced Relationships for models Object Models - Think

    differently When in doubt store in different collection Thursday, May 17, 12
  16. SQL SELECT * FROM Places WHERE acos(sin(1.3963) * sin(Lat) +

    cos(1.3963) * cos(Lat) * cos(Lon - (-0.6981))) * 6371 <= 1000; Thursday, May 17, 12
  17. Query within a rectangle Circle with a center point and

    radius Search within a polygon ( >= 1.9 ) Bound Queries Thursday, May 17, 12
  18. Spherical Model Use decimal degrees - 42.53 Use [longitude, latitude]

    as ordering Use radians for distance $nearSphere and $centerSphere Thursday, May 17, 12
  19. What is Sharding Allows MongoDB to scale horizontally Evenly distributes

    chunks of data Performed per collection Thursday, May 17, 12
  20. Disadvantages No inherit transaction support Scaling sometimes isn’t simple Multiple

    servers recommended Object modeling can be complex Thursday, May 17, 12
  21. The big data loss debate Internet flame war history Mongo

    performs one write at a time - global lock Stored in memory Replication - fail over Thursday, May 17, 12