SlideShare a Scribd company logo
1 of 61
Download to read offline
distilled




            Boris Trofimov
            Team Lead@Sigma Ukraine


            @b0ris_1
            btrofimoff@gmail.com
Agenda
●
    Part 1. Why NoSQL
    –   SQL benefints and critics
    –   NoSQL challange
●
    Part 2. MongoDB
    –   Overview
    –   Console and query example
    –   Java Integration
    –   Data consistancy
    –   Scaling
    –   Tips
Part 1. Why NoSQL
Relational DBMS Benefits
SQL

●
    Simplicity
●
    Uniform representation
●
    Runtime schema modifications

     SELECT DISTINCT p.LastName, p.FirstName
     FROM Person.Person AS p
     JOIN HumanResources.Employee AS e
         ON e.BusinessEntityID = p.BusinessEntityID WHERE 5000.00 IN
         (SELECT Bonus
          FROM Sales.SalesPerson AS sp
          WHERE e.BusinessEntityID = sp.BusinessEntityID);
Strong schema definition
Strong consistency
     SQL features like
     Foreign and Primary Keys, Unique
     fields




     ACID (atomicity, consistency, isolation,
     durability) transactions

     Business transactions ~ system transactions
RDBMS Criticism
Big gap between domain and
      relational model
Performance Issues



JOINS Minimization   Query Optimization     Choosing right transaction strategy



        Consistency costs too much



         Normalization Impact             Performance issues
Schema migration issues
      Consistency issues
      Reinventing bicycle
      Involving external tools like DBDeploy


    Scaling options

         Consistency issues
         Poor scaling options
SQL Opposition

    ●
        Object Databases by OMG
    ●
        ORM
    ●
        ?
No SQL Yes
●
    Transactionaless in usual understanding
●
    Schemaless, no migration
●
    Closer to domain
●
    Focused on aggregates
●
    Trully scalable
NoSQL Umbrella
Key-Value Databases
Column-Family Databases
Document-oriented Databases
Graph-oriented Databases
Aggregate oriented Databases
●
    Document databases implement idea of Aggregate
    oriented database.
●
    Aggregate is a storage atom
●
    Aggregate oriented databsaes are closer to application
    domain.
●
    Ensures atomic operations with aggregate
●
    Aggregate might be replicated or sharded efficiently
●
    Major question: to embed or not to embed
Relations vs Aggregates
// in customers
                   {
                   "id":1,
                   "name":"Medvedev",
                   "billingAddress":[{"city":"Moscow"}]
                   }

                   // in orders
                   {
                   "id":99,
                   "customerId":1,
                   "orderItems":[
                     {
                     "productId":47,
                     "price": 444.45,
                     "productName": "iPhone 5"
                       }
                     ],
                   "shippingAddress":[{"city":"Moscow"}]
                   "orderPayment":[
                     {
                       "ccinfo":"1000-1000-1000-1000",
                       "txnId":"abelif879rft",
                       "billingAddress": {"city": "Moscow"}
                     }
                     ],
                   }


Relational Model   Document Model
Part 2. MongoDB
MongoDB Basics

                 MongoDB is document-
                 oriented and DBMS
                 MongoDB is Client-Server
                 DBMS
                 JSON/JavaScript is major
                  language to access



Mongo DB = Collections + Indexes
Collections
       Name
       Documents




       Indexes




Two documents from the same
collection might be completly different


Simple creating (during first insert).
Document
    Identifier (_id)

    Body i JSON (Internally BSON)
    {
     "fullName" : "Fedor Buhankin",
     "course" : 5,
     "univercity" : "ONPU",
     "faculty" : "IKS",
     "_id" : {   "$oid" : "5071c043cc93742e0d0e9cc7"   }
     "homeAddress" : "Ukraine, Odessa 23/34",
     "averageAssessment" : 5,
     "subjects" : [
                     "math",
                     "literature",
                     "drawing",
                     "psychology"
                   ]
     }


●
    Major bricks: scalar value, map and list
●
    Any part of the ducument can be indexed
●
    Max document size is 16M
MongoDB Console
Query Examples
// in customers
                        {

Simple Select           "id":1,
                        "name":"Medvedev",
                        "billingAddress":[{"city":"Moscow"}]
                        }

                        // in orders
SELECT * FROM ORDERS;   {
                        "id":99,
                        "customerId":1,
                        "orderItems":[
                          {
                          "productId":47,
                          "price": 444.45,
                          "productName": "iPhone 5"
                            }
db.orders.find()          ],
                        "shippingAddress":[{"city":"Moscow"}],
                        "orderPayment":[
                          {
                            "ccinfo":"1000-1000-1000-1000",
                            "txnId":"abelif879rft",
                            "billingAddress": {"city": "Moscow"}
                          }
                          ]
                        }
// in customers
                                     {


Simple Condition                     "id":1,
                                     "name":"Medvedev",
                                     "billingAddress":[{"city":"Moscow"}]
                                     }

                                     // in orders
SELECT * FROM ORDERS WHERE           {
                                     "id":99,
                                     "customerId":1,
customerId = 1;                      "orderItems":[
                                       {
                                       "productId":47,
                                       "price": 444.45,
                                       "productName": "iPhone 5"
                                         }
db.orders.find( {"customerId":1} )     ],
                                     "shippingAddress":[{"city":"Moscow"}],
                                     "orderPayment":[
                                       {
                                         "ccinfo":"1000-1000-1000-1000",
                                         "txnId":"abelif879rft",
                                         "billingAddress": {"city": "Moscow"}
                                       }
                                       ]
                                     }
// in customers
                                                 {


Simple Comparison                                "id":1,
                                                 "name":"Medvedev",
                                                 "billingAddress":[{"city":"Moscow"}]
                                                 }

                                                  // in orders
SELECT *                                          {
                                                  "id":99,
FROM orders                                       "customerId":1,
                                                  "orderItems":[
                                                    {
WHERE customerId > 1                                "productId":47,
                                                    "price": 444.45,
                                                    "productName": "iPhone 5"
                                                      }
                                                    ],
                                                  "shippingAddress":[{"city":"Moscow"}],
db.orders.find({ "customerId" : { $gt: 1 } }   ); "orderPayment":[
                                                    {
                                                      "ccinfo":"1000-1000-1000-1000",
                                                      "txnId":"abelif879rft",
                                                      "billingAddress": {"city": "Moscow"}
                                                    }
                                                    ]
                                                  }
// in customers
                                              {


AND Condition                                 "id":1,
                                              "name":"Medvedev",
                                              "billingAddress":[{"city":"Moscow"}]
                                              }

                                              // in orders
SELECT *                                      {
                                              "id":99,
FROM orders                                   "customerId":1,
                                              "orderItems":[
                                                {
WHERE customerId = 1 AND                        "productId":47,
                                                "price": 444.45,
       orderDate is not NULL                    "productName": "iPhone 5"
                                                  }
                                                ],
                                              "shippingAddress":[{"city":"Moscow"}],
                                              "orderPayment":[
                                                {
db.orders.find( { customerId:1, orderDate :       "ccinfo":"1000-1000-1000-1000",
                                                  "txnId":"abelif879rft",
{ $exists : true } } );                           "billingAddress": {"city": "Moscow"}
                                                }
                                                ]
                                              }
// in customers
                                            {


OR Condition                                "id":1,
                                            "name":"Medvedev",
                                            "billingAddress":[{"city":"Moscow"}]
                                            }

                                            // in orders
SELECT *                                    {
                                            "id":99,
FROM orders                                 "customerId":1,
                                            "orderItems":[
                                              {
WHERE customerId = 100 OR                     "productId":47,
                                              "price": 444.45,
       orderDate is not NULL                  "productName": "iPhone 5"
                                                }
                                              ],
                                            "shippingAddress":[{"city":"Moscow"}],
                                            "orderPayment":[
                                              {
db.orders.find( { $or:[ {customerId:100},       "ccinfo":"1000-1000-1000-1000",
                                                "txnId":"abelif879rft",
{orderDate : { $exists : false }} ] } );
                                                "billingAddress": {"city": "Moscow"}
                                              }
                                              ]
                                            }
// in customers
                                 {


Select fields                    "id":1,
                                 "name":"Medvedev",
                                 "billingAddress":[{"city":"Moscow"}]
                                 }

                                 // in orders
SELECT orderId,   orderDate      {
                                 "id":99,
FROM orders                      "customerId":1,
                                 "orderItems":[
                                   {
WHERE customerId = 1               "productId":47,
                                   "price": 444.45,
                                   "productName": "iPhone 5"
                                     }
db.orders.find({customerId:1},     ],
{orderId:1,orderDate:1})         "shippingAddress":[{"city":"Moscow"}],
                                 "orderPayment":[
                                   {
                                     "ccinfo":"1000-1000-1000-1000",
                                     "txnId":"abelif879rft",
                                     "billingAddress": {"city": "Moscow"}
                                   }
                                   ]
                                 }
// in customers
                                              {


 Inner select                                 "id":1,
                                              "name":"Medvedev",
                                              "billingAddress":[{"city":"Moscow"}]
                                              }

                                              // in orders
SELECT *                                      {
                                              "id":99,
FROM                                          "customerId":1,
                                              "orderItems":[
   Orders                                       {
WHERE                                           "productId":47,
                                                "price": 444.45,
   Orders.id IN (                               "productName": "iPhone 5"
                                                  }
       SELECT id FROM orderItem                 ],
                                              "shippingAddress":[{"city":"Moscow"}],
                                              "orderPayment":[
       WHERE productName LIKE '%iPhone%'        {
                                                  "ccinfo":"1000-1000-1000-1000",
   )                                              "txnId":"abelif879rft",
                                                  "billingAddress": {"city": "Moscow"}
db.orders.find(                                 }
                                                ]
    {"orderItems.productName":/.*iPhone.*/}
                                              }
  )
// in customers
                                         {


NULL checks                              "id":1,
                                         "name":"Medvedev",
                                         "billingAddress":[{"city":"Moscow"}]
                                         }

                                         // in orders
SELECT *                                 {
                                         "id":99,
FROM orders                              "customerId":1,
                                         "orderItems":[
                                           {
WHERE orderDate is NULL                    "productId":47,
                                           "price": 444.45,
                                           "productName": "iPhone 5"
                                             }
                                           ],
                                         "shippingAddress":[{"city":"Moscow"}],
db.orders.find(                          "orderPayment":[
   { orderDate : { $exists : false } }     {
                                             "ccinfo":"1000-1000-1000-1000",
);                                           "txnId":"abelif879rft",
                                             "billingAddress": {"city": "Moscow"}
                                           }
                                           ]
                                         }
More examples
• db.orders.sort().skip(20).limit(10)

• db.orders.count({ "orderItems.price" : { $gt: 444 })

• db.orders.find( { orderItems: { "productId":47, "price": 444.45,
  "productName": "iPhone 5" } } );

• db.orders.find()._addSpecial( "$comment" , "this is tagged query" )
Queries between collections
●
    Remember, MongoDB = no JOINs


●
    1 approach: Perform multiple queries (lazy loading)
●
    2 approach: use MapReduce framework
●
    3 approach: use Aggregation Framework
Map Reduce Framework
●
    Is used to perform complex grouping with collection
    documents
●
    Is able to manipulate over multiple collections
●
    Uses MapReduce pattern
●
    Use JavaScript language
●
    Support sharded environment
●
    The result is similar to materialized views
Map Reduce Concept
         Launch map            Launch reduce
        For every elem




 a11        map
            map           b1
                           1



 a22        map
            map           b2
                           2



 a33        map
            map           b3
                           3



 a44        map
            map           b4
                           4
                                     reduce
                                     reduce             c

 a55        map
            map           b5
                           5



 a66        map
            map           b6
                           6

...                      ...


 ann        map
            map           bn
                           n



       f map : A → B               f reduce : B[ ]→ C
How it works
Input    Implement REDUCE function

          Implement MAP function
                                     Collection X




MAP         Execute MAP func:
            Mark each document
             with specific color




REDUCE
           Execute REDUCE func:
           Merge each colored set
             into single element

                                     Output
Take amount of orders for each customer
db.cutomers_orders.remove();

mapUsers = function() {
    emit( this.customerId, {count: 1, this.customerId} );
};


reduce = function(key, values) {
    var result = {count: 0, customerId:key};

       values.forEach(function(value) {
         result.count += value.count;
       });

       return result;
  };

db.customers.mapReduce(mapUsers, reduce, {"out": {"replace"
"cutomers_orders"}});


Output: [ {count:123, customerId:1}, {count:33, customerId:2} ]
Aggregation and
          Aggregation Framework
●
    Simplify most used mapreduce operarions like
    group by criteria
●
    Restriction on pipeline size is 16MB
●
    Support sharded environment (Aggregation
    Framework only)
Indexes

●
    Anything might be indexed
●
    Indexes improve performance
●
    Implementation uses B-trees
Access via API
Use Official MongoDB Java Driver (just include mongo.jar)
Mongo m =   new Mongo();
// or
Mongo m =   new Mongo( "localhost" );
// or
Mongo m =   new Mongo( "localhost" , 27017 );
// or, to   connect to a replica set, supply a seed list of members
Mongo m =   new Mongo(Arrays.asList(new ServerAddress("localhost", 27017),
                                        new ServerAddress("localhost", 27018),
                                        new ServerAddress("localhost", 27019)))

DB db = m.getDB( "mydb" );

DBCollection coll = db.getCollection("customers");



ArrayList list = new ArrayList();

    list.add(new BasicDBObject("city", "Odessa"));

BasicDBObject doc= new BasicDBObject();

    doc.put("name", "Kaktus");
    doc.put("billingAddress", list);

coll.insert(doc);
Closer to Domain model
●
    Morphia http://code.google.com/p/morphia/
●
    Spring Data for MongoDB
    http://www.springsource.org/spring-data/mongodb

                        Major features:
                    ●
                        Type-safe POJO centric model
                    ●
                        Annotations based mapping behavior
                    ●
                        Good performance
                    ●
                        DAO templates
                    ●
                        Simple criterias
Example with Morphia
@Entity("Customers")
class Customer {
  @Id ObjectId id; // auto-generated, if not set (see ObjectId)
  @Indexed String name; // value types are automatically persisted

     List<Address> billingAddress; // by default fields are @Embedded

     Key<Customer> bestFriend; //referenceto external document
     @Reference List<Customer> partners = new ArrayList<Customer>(); //refs are
     stored and loaded automatically

    // ... getters and setters

     //Lifecycle methods -- Pre/PostLoad, Pre/PostPersist...
     @PostLoad void postLoad(DBObject dbObj) { ... }
}

Datastore ds = new Morphia(new Mongo()).createDatastore("tempDB")

morphia.map(Customer.class);

Key<Customer> newCustomer = ds.save(new Customer("Kaktus",...));

Customer customer = ds.find(Customer.class).field("name").equal("Medvedev").get();
To embed or not to embed
     ●
         Separate collections are good if you need
         to select individual documents, need
         more control over querying, or have huge
         documents.


     ●
         Embedded documents are good when
         you want the entire document, size of the
         document is predicted. Embedded
         documents provide perfect performance.
Schema migration
●
    Schemaless
●
    Main focus is how the aplication will behave when
    new field will has been added
●
    Incremental migration technque (version field)
    Use Cases :
    –   removing field
    –   renaming fields
    –   refactoring aggregate
Data Consistency
●
    Transactional consistency
    –   domain design should take into account aggregate atomicity
●
    Replication consistency
    –   Take into account Inconsistency window (sticky sessions)
●
    Eventual consistency
●
    Accept CAP theorem
    –   it is impossible for a distributed computer system to simultaneously provide all
        three of the following guarantees: consistency, availability and partition
        tolerance.
Scaling
Scaling options

●
    Autosharding
●
    Master-Slave replication
●
    Replica Set clusterization
●
    Sharding + Replica Set
Sharding
●
    MongoDB supports autosharding
●
    Just specify shard key and pattern
●
    Sharding increases writes
●
    Major way for scaling the system
Master-Slave replication
●
    One master, many slaves
●
    Slaves might be hidden or can be used to read
●
    Master-Slave increase
    reades and provides
    reliability
Replica Set clusterization
●
    The replica set automatically elects a primary (master)
●
    Master shares the same state between all replicas
●
    Limitation (limit: 12 nodes)
●
    WriteConcern option
●
    Benefits:
    –   Failover and Reliability
    –   Distributing read load
    –   maintance without downtime
Sharding + ReplicaSet
●
    Allows to build huge scalable failover database
MongoDB Criticism

●
    Dataloss reports on heavy-write configurations
●
    Atomic operatons over multiple documents


                When not to use

●
    Heavy cross-document atomic operations
●
    Queries against varying aggregate structure
Tips
●
    Do not use autoincrement ids
●
    Small names are are preffered
●
    By default DAO methods are async
●
    Think twise on collection design
●
    Use atomic modifications for a document
Out of scope
●
    MapReduce options
●
    Indexes
●
    Capped collections
Further reading

http://www.mongodb.org



Martin Fowler NoSQL Distilled



Kyle Banker, MongoDB in Action
Thank you!

More Related Content

Viewers also liked

Spark-driven audience counting by Boris Trofimov
Spark-driven audience counting by Boris TrofimovSpark-driven audience counting by Boris Trofimov
Spark-driven audience counting by Boris TrofimovJavaDayUA
 
Code contracts by Dmytro Mindra
Code contracts by Dmytro MindraCode contracts by Dmytro Mindra
Code contracts by Dmytro MindraAlex Tumanoff
 
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.GeeksLab Odessa
 
Microsoft Office 2013 новая модель разработки приложений
Microsoft Office 2013 новая модель разработки приложенийMicrosoft Office 2013 новая модель разработки приложений
Microsoft Office 2013 новая модель разработки приложенийAlex Tumanoff
 
LightSwitch - different way to create business applications
LightSwitch - different way to create business applicationsLightSwitch - different way to create business applications
LightSwitch - different way to create business applicationsAlex Tumanoff
 
Enterprise or not to enterprise
Enterprise or not to enterpriseEnterprise or not to enterprise
Enterprise or not to enterpriseAlex Tumanoff
 
Kostenko ux november-2014_1
Kostenko ux november-2014_1Kostenko ux november-2014_1
Kostenko ux november-2014_1Alex Tumanoff
 

Viewers also liked (7)

Spark-driven audience counting by Boris Trofimov
Spark-driven audience counting by Boris TrofimovSpark-driven audience counting by Boris Trofimov
Spark-driven audience counting by Boris Trofimov
 
Code contracts by Dmytro Mindra
Code contracts by Dmytro MindraCode contracts by Dmytro Mindra
Code contracts by Dmytro Mindra
 
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
 
Microsoft Office 2013 новая модель разработки приложений
Microsoft Office 2013 новая модель разработки приложенийMicrosoft Office 2013 новая модель разработки приложений
Microsoft Office 2013 новая модель разработки приложений
 
LightSwitch - different way to create business applications
LightSwitch - different way to create business applicationsLightSwitch - different way to create business applications
LightSwitch - different way to create business applications
 
Enterprise or not to enterprise
Enterprise or not to enterpriseEnterprise or not to enterprise
Enterprise or not to enterprise
 
Kostenko ux november-2014_1
Kostenko ux november-2014_1Kostenko ux november-2014_1
Kostenko ux november-2014_1
 

Similar to Distilled mongo db by Boris Trofimov

MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: TutorialMongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: TutorialMongoDB
 
Webinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDBWebinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDBMongoDB
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichNorberto Leite
 
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2MongoDB
 
Streaming Data Pipelines with MongoDB and Kafka at ao.com
Streaming Data Pipelines with MongoDB and Kafka at ao.comStreaming Data Pipelines with MongoDB and Kafka at ao.com
Streaming Data Pipelines with MongoDB and Kafka at ao.comMongoDB
 
MongoDB Distilled
MongoDB DistilledMongoDB Distilled
MongoDB Distilledb0ris_1
 
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018Keshav Murthy
 
Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Maxime Beugnet
 
Joins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation EnhancementsJoins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation EnhancementsAndrew Morgan
 
SDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - JapanSDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - Japantristansokol
 
Mongodb intro
Mongodb introMongodb intro
Mongodb introchristkv
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live HackingTobias Trelle
 
MongoDB Aggregations Indexing and Profiling
MongoDB Aggregations Indexing and ProfilingMongoDB Aggregations Indexing and Profiling
MongoDB Aggregations Indexing and ProfilingManish Kapoor
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsMongoDB
 
IBM Db2 JSON 11.5
IBM  Db2 JSON 11.5IBM  Db2 JSON 11.5
IBM Db2 JSON 11.5Phil Downey
 
Data Analytics with MongoDB - Jane Fine
Data Analytics with MongoDB - Jane FineData Analytics with MongoDB - Jane Fine
Data Analytics with MongoDB - Jane FineMongoDB
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentationMurat Çakal
 
Semi Formal Model for Document Oriented Databases
Semi Formal Model for Document Oriented DatabasesSemi Formal Model for Document Oriented Databases
Semi Formal Model for Document Oriented DatabasesDaniel Coupal
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation Amit Ghosh
 

Similar to Distilled mongo db by Boris Trofimov (20)

MongoDB Meetup
MongoDB MeetupMongoDB Meetup
MongoDB Meetup
 
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: TutorialMongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
 
Webinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDBWebinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDB
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days Munich
 
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
 
Streaming Data Pipelines with MongoDB and Kafka at ao.com
Streaming Data Pipelines with MongoDB and Kafka at ao.comStreaming Data Pipelines with MongoDB and Kafka at ao.com
Streaming Data Pipelines with MongoDB and Kafka at ao.com
 
MongoDB Distilled
MongoDB DistilledMongoDB Distilled
MongoDB Distilled
 
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
 
Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...
 
Joins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation EnhancementsJoins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation Enhancements
 
SDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - JapanSDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - Japan
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live Hacking
 
MongoDB Aggregations Indexing and Profiling
MongoDB Aggregations Indexing and ProfilingMongoDB Aggregations Indexing and Profiling
MongoDB Aggregations Indexing and Profiling
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
 
IBM Db2 JSON 11.5
IBM  Db2 JSON 11.5IBM  Db2 JSON 11.5
IBM Db2 JSON 11.5
 
Data Analytics with MongoDB - Jane Fine
Data Analytics with MongoDB - Jane FineData Analytics with MongoDB - Jane Fine
Data Analytics with MongoDB - Jane Fine
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentation
 
Semi Formal Model for Document Oriented Databases
Semi Formal Model for Document Oriented DatabasesSemi Formal Model for Document Oriented Databases
Semi Formal Model for Document Oriented Databases
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation
 

More from Alex Tumanoff

Sql server 2019 New Features by Yevhen Nedaskivskyi
Sql server 2019 New Features by Yevhen NedaskivskyiSql server 2019 New Features by Yevhen Nedaskivskyi
Sql server 2019 New Features by Yevhen NedaskivskyiAlex Tumanoff
 
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis ReznikOdessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis ReznikAlex Tumanoff
 
Azure data bricks by Eugene Polonichko
Azure data bricks by Eugene PolonichkoAzure data bricks by Eugene Polonichko
Azure data bricks by Eugene PolonichkoAlex Tumanoff
 
Sdlc by Anatoliy Anthony Cox
Sdlc by  Anatoliy Anthony CoxSdlc by  Anatoliy Anthony Cox
Sdlc by Anatoliy Anthony CoxAlex Tumanoff
 
Java 8 in action.jinq.v.1.3
Java 8 in action.jinq.v.1.3Java 8 in action.jinq.v.1.3
Java 8 in action.jinq.v.1.3Alex Tumanoff
 
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас..."Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...Alex Tumanoff
 
Sql saturday azure storage by Anton Vidishchev
Sql saturday azure storage by Anton VidishchevSql saturday azure storage by Anton Vidishchev
Sql saturday azure storage by Anton VidishchevAlex Tumanoff
 
Navigation map factory by Alexey Klimenko
Navigation map factory by Alexey KlimenkoNavigation map factory by Alexey Klimenko
Navigation map factory by Alexey KlimenkoAlex Tumanoff
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsAlex Tumanoff
 
Игры для мобильных платформ by Алексей Рыбаков
Игры для мобильных платформ by Алексей РыбаковИгры для мобильных платформ by Алексей Рыбаков
Игры для мобильных платформ by Алексей РыбаковAlex Tumanoff
 
Android sync adapter
Android sync adapterAndroid sync adapter
Android sync adapterAlex Tumanoff
 
Async clinic by by Sergey Teplyakov
Async clinic by by Sergey TeplyakovAsync clinic by by Sergey Teplyakov
Async clinic by by Sergey TeplyakovAlex Tumanoff
 
Deep Dive C# by Sergey Teplyakov
Deep Dive  C# by Sergey TeplyakovDeep Dive  C# by Sergey Teplyakov
Deep Dive C# by Sergey TeplyakovAlex Tumanoff
 
Bdd by Dmitri Aizenberg
Bdd by Dmitri AizenbergBdd by Dmitri Aizenberg
Bdd by Dmitri AizenbergAlex Tumanoff
 
Неформальные размышления о сертификации в IT
Неформальные размышления о сертификации в ITНеформальные размышления о сертификации в IT
Неформальные размышления о сертификации в ITAlex Tumanoff
 
Разработка расширений Firefox
Разработка расширений FirefoxРазработка расширений Firefox
Разработка расширений FirefoxAlex Tumanoff
 
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So..."AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...Alex Tumanoff
 
Patterns of parallel programming
Patterns of parallel programmingPatterns of parallel programming
Patterns of parallel programmingAlex Tumanoff
 
Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8Alex Tumanoff
 

More from Alex Tumanoff (20)

Sql server 2019 New Features by Yevhen Nedaskivskyi
Sql server 2019 New Features by Yevhen NedaskivskyiSql server 2019 New Features by Yevhen Nedaskivskyi
Sql server 2019 New Features by Yevhen Nedaskivskyi
 
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis ReznikOdessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
 
Azure data bricks by Eugene Polonichko
Azure data bricks by Eugene PolonichkoAzure data bricks by Eugene Polonichko
Azure data bricks by Eugene Polonichko
 
Sdlc by Anatoliy Anthony Cox
Sdlc by  Anatoliy Anthony CoxSdlc by  Anatoliy Anthony Cox
Sdlc by Anatoliy Anthony Cox
 
Java 8 in action.jinq.v.1.3
Java 8 in action.jinq.v.1.3Java 8 in action.jinq.v.1.3
Java 8 in action.jinq.v.1.3
 
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас..."Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
 
Spring.new hope.1.3
Spring.new hope.1.3Spring.new hope.1.3
Spring.new hope.1.3
 
Sql saturday azure storage by Anton Vidishchev
Sql saturday azure storage by Anton VidishchevSql saturday azure storage by Anton Vidishchev
Sql saturday azure storage by Anton Vidishchev
 
Navigation map factory by Alexey Klimenko
Navigation map factory by Alexey KlimenkoNavigation map factory by Alexey Klimenko
Navigation map factory by Alexey Klimenko
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey Morenets
 
Игры для мобильных платформ by Алексей Рыбаков
Игры для мобильных платформ by Алексей РыбаковИгры для мобильных платформ by Алексей Рыбаков
Игры для мобильных платформ by Алексей Рыбаков
 
Android sync adapter
Android sync adapterAndroid sync adapter
Android sync adapter
 
Async clinic by by Sergey Teplyakov
Async clinic by by Sergey TeplyakovAsync clinic by by Sergey Teplyakov
Async clinic by by Sergey Teplyakov
 
Deep Dive C# by Sergey Teplyakov
Deep Dive  C# by Sergey TeplyakovDeep Dive  C# by Sergey Teplyakov
Deep Dive C# by Sergey Teplyakov
 
Bdd by Dmitri Aizenberg
Bdd by Dmitri AizenbergBdd by Dmitri Aizenberg
Bdd by Dmitri Aizenberg
 
Неформальные размышления о сертификации в IT
Неформальные размышления о сертификации в ITНеформальные размышления о сертификации в IT
Неформальные размышления о сертификации в IT
 
Разработка расширений Firefox
Разработка расширений FirefoxРазработка расширений Firefox
Разработка расширений Firefox
 
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So..."AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
 
Patterns of parallel programming
Patterns of parallel programmingPatterns of parallel programming
Patterns of parallel programming
 
Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8
 

Distilled mongo db by Boris Trofimov

  • 1. distilled Boris Trofimov Team Lead@Sigma Ukraine @b0ris_1 btrofimoff@gmail.com
  • 2. Agenda ● Part 1. Why NoSQL – SQL benefints and critics – NoSQL challange ● Part 2. MongoDB – Overview – Console and query example – Java Integration – Data consistancy – Scaling – Tips
  • 3. Part 1. Why NoSQL
  • 5. SQL ● Simplicity ● Uniform representation ● Runtime schema modifications SELECT DISTINCT p.LastName, p.FirstName FROM Person.Person AS p JOIN HumanResources.Employee AS e ON e.BusinessEntityID = p.BusinessEntityID WHERE 5000.00 IN (SELECT Bonus FROM Sales.SalesPerson AS sp WHERE e.BusinessEntityID = sp.BusinessEntityID);
  • 7. Strong consistency SQL features like Foreign and Primary Keys, Unique fields ACID (atomicity, consistency, isolation, durability) transactions Business transactions ~ system transactions
  • 9. Big gap between domain and relational model
  • 10. Performance Issues JOINS Minimization Query Optimization Choosing right transaction strategy Consistency costs too much Normalization Impact Performance issues
  • 11. Schema migration issues Consistency issues Reinventing bicycle Involving external tools like DBDeploy Scaling options Consistency issues Poor scaling options
  • 12. SQL Opposition ● Object Databases by OMG ● ORM ● ?
  • 13. No SQL Yes ● Transactionaless in usual understanding ● Schemaless, no migration ● Closer to domain ● Focused on aggregates ● Trully scalable
  • 19. Aggregate oriented Databases ● Document databases implement idea of Aggregate oriented database. ● Aggregate is a storage atom ● Aggregate oriented databsaes are closer to application domain. ● Ensures atomic operations with aggregate ● Aggregate might be replicated or sharded efficiently ● Major question: to embed or not to embed
  • 21. // in customers { "id":1, "name":"Medvedev", "billingAddress":[{"city":"Moscow"}] } // in orders { "id":99, "customerId":1, "orderItems":[ { "productId":47, "price": 444.45, "productName": "iPhone 5" } ], "shippingAddress":[{"city":"Moscow"}] "orderPayment":[ { "ccinfo":"1000-1000-1000-1000", "txnId":"abelif879rft", "billingAddress": {"city": "Moscow"} } ], } Relational Model Document Model
  • 23. MongoDB Basics MongoDB is document- oriented and DBMS MongoDB is Client-Server DBMS JSON/JavaScript is major language to access Mongo DB = Collections + Indexes
  • 24. Collections Name Documents Indexes Two documents from the same collection might be completly different Simple creating (during first insert).
  • 25. Document Identifier (_id) Body i JSON (Internally BSON) { "fullName" : "Fedor Buhankin", "course" : 5, "univercity" : "ONPU", "faculty" : "IKS", "_id" : { "$oid" : "5071c043cc93742e0d0e9cc7" } "homeAddress" : "Ukraine, Odessa 23/34", "averageAssessment" : 5, "subjects" : [ "math", "literature", "drawing", "psychology" ] } ● Major bricks: scalar value, map and list ● Any part of the ducument can be indexed ● Max document size is 16M
  • 28. // in customers { Simple Select "id":1, "name":"Medvedev", "billingAddress":[{"city":"Moscow"}] } // in orders SELECT * FROM ORDERS; { "id":99, "customerId":1, "orderItems":[ { "productId":47, "price": 444.45, "productName": "iPhone 5" } db.orders.find() ], "shippingAddress":[{"city":"Moscow"}], "orderPayment":[ { "ccinfo":"1000-1000-1000-1000", "txnId":"abelif879rft", "billingAddress": {"city": "Moscow"} } ] }
  • 29. // in customers { Simple Condition "id":1, "name":"Medvedev", "billingAddress":[{"city":"Moscow"}] } // in orders SELECT * FROM ORDERS WHERE { "id":99, "customerId":1, customerId = 1; "orderItems":[ { "productId":47, "price": 444.45, "productName": "iPhone 5" } db.orders.find( {"customerId":1} ) ], "shippingAddress":[{"city":"Moscow"}], "orderPayment":[ { "ccinfo":"1000-1000-1000-1000", "txnId":"abelif879rft", "billingAddress": {"city": "Moscow"} } ] }
  • 30. // in customers { Simple Comparison "id":1, "name":"Medvedev", "billingAddress":[{"city":"Moscow"}] } // in orders SELECT * { "id":99, FROM orders "customerId":1, "orderItems":[ { WHERE customerId > 1 "productId":47, "price": 444.45, "productName": "iPhone 5" } ], "shippingAddress":[{"city":"Moscow"}], db.orders.find({ "customerId" : { $gt: 1 } } ); "orderPayment":[ { "ccinfo":"1000-1000-1000-1000", "txnId":"abelif879rft", "billingAddress": {"city": "Moscow"} } ] }
  • 31. // in customers { AND Condition "id":1, "name":"Medvedev", "billingAddress":[{"city":"Moscow"}] } // in orders SELECT * { "id":99, FROM orders "customerId":1, "orderItems":[ { WHERE customerId = 1 AND "productId":47, "price": 444.45, orderDate is not NULL "productName": "iPhone 5" } ], "shippingAddress":[{"city":"Moscow"}], "orderPayment":[ { db.orders.find( { customerId:1, orderDate : "ccinfo":"1000-1000-1000-1000", "txnId":"abelif879rft", { $exists : true } } ); "billingAddress": {"city": "Moscow"} } ] }
  • 32. // in customers { OR Condition "id":1, "name":"Medvedev", "billingAddress":[{"city":"Moscow"}] } // in orders SELECT * { "id":99, FROM orders "customerId":1, "orderItems":[ { WHERE customerId = 100 OR "productId":47, "price": 444.45, orderDate is not NULL "productName": "iPhone 5" } ], "shippingAddress":[{"city":"Moscow"}], "orderPayment":[ { db.orders.find( { $or:[ {customerId:100}, "ccinfo":"1000-1000-1000-1000", "txnId":"abelif879rft", {orderDate : { $exists : false }} ] } ); "billingAddress": {"city": "Moscow"} } ] }
  • 33. // in customers { Select fields "id":1, "name":"Medvedev", "billingAddress":[{"city":"Moscow"}] } // in orders SELECT orderId, orderDate { "id":99, FROM orders "customerId":1, "orderItems":[ { WHERE customerId = 1 "productId":47, "price": 444.45, "productName": "iPhone 5" } db.orders.find({customerId:1}, ], {orderId:1,orderDate:1}) "shippingAddress":[{"city":"Moscow"}], "orderPayment":[ { "ccinfo":"1000-1000-1000-1000", "txnId":"abelif879rft", "billingAddress": {"city": "Moscow"} } ] }
  • 34. // in customers { Inner select "id":1, "name":"Medvedev", "billingAddress":[{"city":"Moscow"}] } // in orders SELECT * { "id":99, FROM "customerId":1, "orderItems":[ Orders { WHERE "productId":47, "price": 444.45, Orders.id IN ( "productName": "iPhone 5" } SELECT id FROM orderItem ], "shippingAddress":[{"city":"Moscow"}], "orderPayment":[ WHERE productName LIKE '%iPhone%' { "ccinfo":"1000-1000-1000-1000", ) "txnId":"abelif879rft", "billingAddress": {"city": "Moscow"} db.orders.find( } ] {"orderItems.productName":/.*iPhone.*/} } )
  • 35. // in customers { NULL checks "id":1, "name":"Medvedev", "billingAddress":[{"city":"Moscow"}] } // in orders SELECT * { "id":99, FROM orders "customerId":1, "orderItems":[ { WHERE orderDate is NULL "productId":47, "price": 444.45, "productName": "iPhone 5" } ], "shippingAddress":[{"city":"Moscow"}], db.orders.find( "orderPayment":[ { orderDate : { $exists : false } } { "ccinfo":"1000-1000-1000-1000", ); "txnId":"abelif879rft", "billingAddress": {"city": "Moscow"} } ] }
  • 36. More examples • db.orders.sort().skip(20).limit(10) • db.orders.count({ "orderItems.price" : { $gt: 444 }) • db.orders.find( { orderItems: { "productId":47, "price": 444.45, "productName": "iPhone 5" } } ); • db.orders.find()._addSpecial( "$comment" , "this is tagged query" )
  • 37. Queries between collections ● Remember, MongoDB = no JOINs ● 1 approach: Perform multiple queries (lazy loading) ● 2 approach: use MapReduce framework ● 3 approach: use Aggregation Framework
  • 38. Map Reduce Framework ● Is used to perform complex grouping with collection documents ● Is able to manipulate over multiple collections ● Uses MapReduce pattern ● Use JavaScript language ● Support sharded environment ● The result is similar to materialized views
  • 39. Map Reduce Concept Launch map Launch reduce For every elem a11 map map b1 1 a22 map map b2 2 a33 map map b3 3 a44 map map b4 4 reduce reduce c a55 map map b5 5 a66 map map b6 6 ... ... ann map map bn n f map : A → B f reduce : B[ ]→ C
  • 40. How it works Input Implement REDUCE function Implement MAP function Collection X MAP Execute MAP func: Mark each document with specific color REDUCE Execute REDUCE func: Merge each colored set into single element Output
  • 41. Take amount of orders for each customer db.cutomers_orders.remove(); mapUsers = function() { emit( this.customerId, {count: 1, this.customerId} ); }; reduce = function(key, values) { var result = {count: 0, customerId:key}; values.forEach(function(value) { result.count += value.count; }); return result; }; db.customers.mapReduce(mapUsers, reduce, {"out": {"replace" "cutomers_orders"}}); Output: [ {count:123, customerId:1}, {count:33, customerId:2} ]
  • 42. Aggregation and Aggregation Framework ● Simplify most used mapreduce operarions like group by criteria ● Restriction on pipeline size is 16MB ● Support sharded environment (Aggregation Framework only)
  • 43. Indexes ● Anything might be indexed ● Indexes improve performance ● Implementation uses B-trees
  • 44.
  • 45. Access via API Use Official MongoDB Java Driver (just include mongo.jar) Mongo m = new Mongo(); // or Mongo m = new Mongo( "localhost" ); // or Mongo m = new Mongo( "localhost" , 27017 ); // or, to connect to a replica set, supply a seed list of members Mongo m = new Mongo(Arrays.asList(new ServerAddress("localhost", 27017), new ServerAddress("localhost", 27018), new ServerAddress("localhost", 27019))) DB db = m.getDB( "mydb" ); DBCollection coll = db.getCollection("customers"); ArrayList list = new ArrayList(); list.add(new BasicDBObject("city", "Odessa")); BasicDBObject doc= new BasicDBObject(); doc.put("name", "Kaktus"); doc.put("billingAddress", list); coll.insert(doc);
  • 46. Closer to Domain model ● Morphia http://code.google.com/p/morphia/ ● Spring Data for MongoDB http://www.springsource.org/spring-data/mongodb Major features: ● Type-safe POJO centric model ● Annotations based mapping behavior ● Good performance ● DAO templates ● Simple criterias
  • 47. Example with Morphia @Entity("Customers") class Customer { @Id ObjectId id; // auto-generated, if not set (see ObjectId) @Indexed String name; // value types are automatically persisted List<Address> billingAddress; // by default fields are @Embedded Key<Customer> bestFriend; //referenceto external document @Reference List<Customer> partners = new ArrayList<Customer>(); //refs are stored and loaded automatically // ... getters and setters //Lifecycle methods -- Pre/PostLoad, Pre/PostPersist... @PostLoad void postLoad(DBObject dbObj) { ... } } Datastore ds = new Morphia(new Mongo()).createDatastore("tempDB") morphia.map(Customer.class); Key<Customer> newCustomer = ds.save(new Customer("Kaktus",...)); Customer customer = ds.find(Customer.class).field("name").equal("Medvedev").get();
  • 48. To embed or not to embed ● Separate collections are good if you need to select individual documents, need more control over querying, or have huge documents. ● Embedded documents are good when you want the entire document, size of the document is predicted. Embedded documents provide perfect performance.
  • 49. Schema migration ● Schemaless ● Main focus is how the aplication will behave when new field will has been added ● Incremental migration technque (version field) Use Cases : – removing field – renaming fields – refactoring aggregate
  • 50. Data Consistency ● Transactional consistency – domain design should take into account aggregate atomicity ● Replication consistency – Take into account Inconsistency window (sticky sessions) ● Eventual consistency ● Accept CAP theorem – it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees: consistency, availability and partition tolerance.
  • 52. Scaling options ● Autosharding ● Master-Slave replication ● Replica Set clusterization ● Sharding + Replica Set
  • 53. Sharding ● MongoDB supports autosharding ● Just specify shard key and pattern ● Sharding increases writes ● Major way for scaling the system
  • 54. Master-Slave replication ● One master, many slaves ● Slaves might be hidden or can be used to read ● Master-Slave increase reades and provides reliability
  • 55. Replica Set clusterization ● The replica set automatically elects a primary (master) ● Master shares the same state between all replicas ● Limitation (limit: 12 nodes) ● WriteConcern option ● Benefits: – Failover and Reliability – Distributing read load – maintance without downtime
  • 56. Sharding + ReplicaSet ● Allows to build huge scalable failover database
  • 57. MongoDB Criticism ● Dataloss reports on heavy-write configurations ● Atomic operatons over multiple documents When not to use ● Heavy cross-document atomic operations ● Queries against varying aggregate structure
  • 58. Tips ● Do not use autoincrement ids ● Small names are are preffered ● By default DAO methods are async ● Think twise on collection design ● Use atomic modifications for a document
  • 59. Out of scope ● MapReduce options ● Indexes ● Capped collections
  • 60. Further reading http://www.mongodb.org Martin Fowler NoSQL Distilled Kyle Banker, MongoDB in Action