SlideShare une entreprise Scribd logo
1  sur  176
+)1*3$&4(56&4#70&89::&
                                     !"#$%&'()&*(&+,,&-).&/0($1(.12&




                                                    h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to                    MongoDB
                              A No-SQL Persistence Alternative
 A   U   S   T   I   N    -      C        O        D       E        -      C        A       M     P   -   2   0   1   1




                                   Chris Edwards

                         h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
MongoDB


 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
About Me
         Chris Edwards
         Architect at BancVue Ltd.
            Email: ChrisEdwards357@gmail.com
            Blog: http://chrisedwards.dreamhosters.com
            Twitter: @cedwards
            Github: http://github.com/chrisedwards
                            (Sample code for this talk is posted)




                                                         h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
            •    What is the NoSQL Movement?
            •    What is MongoDB?
            •    Installing
            •    Using the Mongo Shell
            •    Accessing MongoDB via REST
            •    Replication
            •    Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
What is No-SQL?




                                                  h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
What is No-SQL?

                “Next Generation Databases mostly addressing some of the points:
                being non-relational, distributed, open-source and horizontal
                scalable. ... schema-free, easy replication support, simple API,
                eventually consistent ...”
                                                                       - nosql-database.org




                                                  h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
What is No-SQL?

                “Next Generation Databases mostly addressing some of the points:
                being non-relational, distributed, open-source and horizontal
                scalable. ... schema-free, easy replication support, simple API,
                eventually consistent ...”
                                                                       - nosql-database.org




                  •    Non-Relational                                                           •     Schema-Free
                  •    Distributed                                                              •     Replication Support
                  •    Open-Source                                                              •     Simple API
                  •    Horizontally Scalable                                                    •     Eventually Consistent

                                                  h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
What is No-SQL?
             It’s about using the right tool for the job.
                    • Not all systems have the same data needs.
                    • Sql is not the only option, nor is it always the best one.
                    • Consider all options carefully and choose wisely.




                                                  h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
What is No-SQL?
             It’s about using the right tool for the job.
                    • Not all systems have the same data needs.
                    • Sql is not the only option, nor is it always the best one.
                    • Consider all options carefully and choose wisely.




                               Not Only SQL

                                                  h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
What is No-SQL?
             It’s about using the right tool for the job.
                    • Not all systems have the same data needs.
                    • Sql is not the only option, nor is it always the best one.
                    • Consider all options carefully and choose wisely.




                               Not Only SQL
                                                  It’s not about flaming SQL.

                                                  h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
What is No-SQL?
             It’s about using the right tool for the job.
                    • Not all systems have the same data needs.
                    • Sql is not the only option, nor is it always the best one.
                    • Consider all options carefully and choose wisely.




                               Not Only SQL
                                             It’s not about flaming SQL.
                                  Its about opening our minds to new technologies.
                                                  h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •    What is the NoSQL Movement?
             •    What is MongoDB?
             •    Installing
             •    Using the Mongo Shell
             •    Accessing MongoDB via REST
             •    Replication
             •    Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •    What is the NoSQL Movement?
             •    What is MongoDB?
             •    Installing
             •    Using the Mongo Shell
             •    Accessing MongoDB via REST
             •    Replication
             •    Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
What is MongoDB?
             • Document-oriented database
                     - Uses JSON (BSON actually)
             • Schema-free
             • Performant
                     -   Written in C++
                     -   Full index support
                     -   No transactions (has atomic operations)
                                                                                                                    “Mongo only pawn in game of life”
                     -   Memory-mapped files (delayed writes)
             • Replication & High Availability
             • Auto Sharding
             • Commercially supported (10gen)
                     - Lots of documentation




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
Other Features of MongoDB
             • Document-based queries
                     - Flexible document queries expressed in JSON/Javascript.
             • Map Reduce
                     - Flexible aggregation and data processing.
                     - Queries run in parallel on all shards.
             • GridFS
                     - Store files of any size easily.
             • Geospatial Indexing
                     - Find object based on location. (i.e. find closest n items to x)
             • Many Production Deployments




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
Other Features of MongoDB
             • Supported on Multiple Platforms
                     -   OSX
                     -   Linux
                     -   Solaris
                     -   Windows
                     -   FreeBSD




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Concepts
             Document
             -   Analogous to a row in RDBMS
             -   Represented as JSON (BSON)
             -   Hierarchical
             -   Can reference other documents




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Concepts
             Collection
             -   Analogous to a table in RDBMS
             -   Collection of documents
             -   Documents can be anything
             -   Advantageous if they are similar




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Concepts
             Embedding                                            {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
             -   Analogous to a foreign key                       

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                  

'state':
'in_cart',
             -   Think “pre-joined relationship”.
                                                                  

'line_items':
[
             -   Clearer conceptual model.                        



{
'sku':
'jc‐432',
                                                                  





'name':
'John
Coltrane:
A
Love
Supreme',
             -   DDD Aggregate Root                               





'retail_price':
1099
             -   Can be                                           



},

                    - Sub Objects                                 



{
'sku':
'ly‐211',
                                                                  





'name':
'Larry
Young:
Unity',
                    - Collections                                 





'retail_price':
1199
                                                                  



}
                                                                  

],
                                                                  

'shipping_address':
{
                                                                  



'street':
'3333
Greene
Ave.',
                                                                  



'city':
'Brooklyn',
                                                                  



'state':
'NY',
                                                                  



'zip':
'11216'
                                                                  

},
                                                                  

'subtotal':
2199
                                                                  }




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Concepts
             Embedding                                            {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
             -   Analogous to a foreign key                       

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                  

'state':
'in_cart',
             -   Think “pre-joined relationship”
                                                                  

'line_items':
[
             -   Clearer conceptual model.                        



{
'sku':
'jc‐432',
                                                                  





'name':
'John
Coltrane:
A
Love
Supreme',
             -   DDD Aggregate Root                               





'retail_price':
1099
             -   Can be                                           



},

                    - Sub Objects                                 



{
'sku':
'ly‐211',
                                                                  





'name':
'Larry
Young:
Unity',
                    - Collections                                 





'retail_price':
1199
                                                                  



}
                                                                  

],
                                                                  

'shipping_address':
{
             References                                           



'street':
'3333
Greene
Ave.',
                                                                  



'city':
'Brooklyn',
                                                                  



'state':
'NY',
             - Analogous to a foreign key                         



'zip':
'11216'
                                                                  

},
             - Think “relationship”
                                                                  

'subtotal':
2199
                                                                  }




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Querying
             All the following queries will find the document.



                                                                                                               {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
                                                                                                               

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                               

'state':
'in_cart',

                                                                                                               

'line_items':
[
                                                                                                               



{
'sku':
'jc‐432',
                                                                                                               





'name':
'John
Coltrane:
A
Love
Supreme',
                                                                                                               





'retail_price':
1099
                                                                                                               



},

                                                                                                               



{
'sku':
'ly‐211',
                                                                                                               





'name':
'Larry
Young:
Unity',
                                                                                                               





'retail_price':
1199
                                                                                                               



}
                                                                                                               

],

                                                                                                               

'shipping_address':
{
                                                                                                               



'street':
'3333
Greene
Ave.',
                                                                                                               



'city':
'Brooklyn',
                                                                                                               



'state':
'NY',
                                                                                                               



'zip':
'11216'
                                                                                                               

},

                                                                                                               

'subtotal':
2199
                                                                                                               }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Querying
             All the following queries will find the document.

             By property value
                db.orders.find(
{
"state":
"in_cart"
}
);
                                                                                                               {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
                                                                                                               

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                               

'state':
'in_cart',

                                                                                                               

'line_items':
[
                                                                                                               



{
'sku':
'jc‐432',
                                                                                                               





'name':
'John
Coltrane:
A
Love
Supreme',
                                                                                                               





'retail_price':
1099
                                                                                                               



},

                                                                                                               



{
'sku':
'ly‐211',
                                                                                                               





'name':
'Larry
Young:
Unity',
                                                                                                               





'retail_price':
1199
                                                                                                               



}
                                                                                                               

],

                                                                                                               

'shipping_address':
{
                                                                                                               



'street':
'3333
Greene
Ave.',
                                                                                                               



'city':
'Brooklyn',
                                                                                                               



'state':
'NY',
                                                                                                               



'zip':
'11216'
                                                                                                               

},

                                                                                                               

'subtotal':
2199
                                                                                                               }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Querying
             All the following queries will find the document.

             By property value
                db.orders.find(
{
"state":
"in_cart"
}
);
                                                                                                               {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
             By embedded object property value                                                                 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                               

'state':
'in_cart',
                db.orders.find(
{
"shipping_address.state":
"NY"
}
);                                          

'line_items':
[
                                                                                                               



{
'sku':
'jc‐432',
                                                                                                               





'name':
'John
Coltrane:
A
Love
Supreme',
                                                                                                               





'retail_price':
1099
                                                                                                               



},

                                                                                                               



{
'sku':
'ly‐211',
                                                                                                               





'name':
'Larry
Young:
Unity',
                                                                                                               





'retail_price':
1199
                                                                                                               



}
                                                                                                               

],

                                                                                                               

'shipping_address':
{
                                                                                                               



'street':
'3333
Greene
Ave.',
                                                                                                               



'city':
'Brooklyn',
                                                                                                               



'state':
'NY',
                                                                                                               



'zip':
'11216'
                                                                                                               

},

                                                                                                               

'subtotal':
2199
                                                                                                               }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Querying
             All the following queries will find the document.

             By property value
                db.orders.find(
{
"state":
"in_cart"
}
);
                                                                                                               {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
             By embedded object property value                                                                 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                               

'state':
'in_cart',
                db.orders.find(
{
"shipping_address.state":
"NY"
}
);                                          

'line_items':
[
                                                                                                               



{
'sku':
'jc‐432',
                                                                                                               





'name':
'John
Coltrane:
A
Love
Supreme',
             With comparison operators                                                                         





'retail_price':
1099
                                                                                                               



},

                db.orders.find(
{
"subtotal":
{
$gt:
2000
}
}
);                                               



{
'sku':
'ly‐211',
                                                                                                               





'name':
'Larry
Young:
Unity',
                                                                                                               





'retail_price':
1199
                                                                                                               



}
                                                                                                               

],

                                                                                                               

'shipping_address':
{
                                                                                                               



'street':
'3333
Greene
Ave.',
                                                                                                               



'city':
'Brooklyn',
                                                                                                               



'state':
'NY',
                                                                                                               



'zip':
'11216'
                                                                                                               

},

                                                                                                               

'subtotal':
2199
                                                                                                               }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Querying
             All the following queries will find the document.

             By property value
                db.orders.find(
{
"state":
"in_cart"
}
);
                                                                                                               {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
             By embedded object property value                                                                 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                               

'state':
'in_cart',
                db.orders.find(
{
"shipping_address.state":
"NY"
}
);                                          

'line_items':
[
                                                                                                               



{
'sku':
'jc‐432',
                                                                                                               





'name':
'John
Coltrane:
A
Love
Supreme',
             With comparison operators                                                                         





'retail_price':
1099
                                                                                                               



},

                db.orders.find(
{
"subtotal":
{
$gt:
2000
}
}
);                                               



{
'sku':
'ly‐211',
                                                                                                               





'name':
'Larry
Young:
Unity',
                                                                                                               





'retail_price':
1199
                                                                                                               



}
             Values in collections (implicit “in”)                                                             

],

                 db.orders.find(
{
"line_items.sku":
"ly‐211"
}
);                                             

'shipping_address':
{
                                                                                                               



'street':
'3333
Greene
Ave.',
                                                                                                               



'city':
'Brooklyn',
                                                                                                               



'state':
'NY',
                                                                                                               



'zip':
'11216'
                                                                                                               

},

                                                                                                               

'subtotal':
2199
                                                                                                               }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
           Indexing


                                                                                                                 {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
                                                                                                                 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                                 

'state':
'in_cart',

                                                                                                                 

'line_items':
[
                                                                                                                 



{
'sku':
'jc‐432',
                                                                                                                 





'name':
'John
Coltrane:
A
Love
Supreme',
                                                                                                                 





'retail_price':
1099
                                                                                                                 



},

                                                                                                                 



{
'sku':
'ly‐211',
                                                                                                                 





'name':
'Larry
Young:
Unity',
                                                                                                                 





'retail_price':
1199
                                                                                                                 



}
                                                                                                                 

],

                                                                                                                 

'shipping_address':
{
                                                                                                                 



'street':
'3333
Greene
Ave.',
                                                                                                                 



'city':
'Brooklyn',
                                                                                                                 



'state':
'NY',
                                                                                                                 



'zip':
'11216'
                                                                                                                 

},

                                                                                                                 

'subtotal':
2199
                                                                                                                 }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
           Indexing
           On property value
             db.orders.ensureIndex(
{
"state":
1
}
);



                                                                                                                 {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
                                                                                                                 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                                 

'state':
'in_cart',

                                                                                                                 

'line_items':
[
                                                                                                                 



{
'sku':
'jc‐432',
                                                                                                                 





'name':
'John
Coltrane:
A
Love
Supreme',
                                                                                                                 





'retail_price':
1099
                                                                                                                 



},

                                                                                                                 



{
'sku':
'ly‐211',
                                                                                                                 





'name':
'Larry
Young:
Unity',
                                                                                                                 





'retail_price':
1199
                                                                                                                 



}
                                                                                                                 

],

                                                                                                                 

'shipping_address':
{
                                                                                                                 



'street':
'3333
Greene
Ave.',
                                                                                                                 



'city':
'Brooklyn',
                                                                                                                 



'state':
'NY',
                                                                                                                 



'zip':
'11216'
                                                                                                                 

},

                                                                                                                 

'subtotal':
2199
                                                                                                                 }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
           Indexing
           On property value
             db.orders.ensureIndex(
{
"state":
1
}
);


           On embedded object property
                                                                                                                 {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
             db.orders.ensureIndex(
{
"shipping_address.state":
1
}
);                                           

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                                 

'state':
'in_cart',

                                                                                                                 

'line_items':
[
                                                                                                                 



{
'sku':
'jc‐432',
                                                                                                                 





'name':
'John
Coltrane:
A
Love
Supreme',
                                                                                                                 





'retail_price':
1099
                                                                                                                 



},

                                                                                                                 



{
'sku':
'ly‐211',
                                                                                                                 





'name':
'Larry
Young:
Unity',
                                                                                                                 





'retail_price':
1199
                                                                                                                 



}
                                                                                                                 

],

                                                                                                                 

'shipping_address':
{
                                                                                                                 



'street':
'3333
Greene
Ave.',
                                                                                                                 



'city':
'Brooklyn',
                                                                                                                 



'state':
'NY',
                                                                                                                 



'zip':
'11216'
                                                                                                                 

},

                                                                                                                 

'subtotal':
2199
                                                                                                                 }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
           Indexing
           On property value
             db.orders.ensureIndex(
{
"state":
1
}
);


           On embedded object property
                                                                                                                 {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
             db.orders.ensureIndex(
{
"shipping_address.state":
1
}
);                                           

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                                 

'state':
'in_cart',

                                                                                                                 

'line_items':
[
           On embedded collections                                                                               



{
'sku':
'jc‐432',
                                                                                                                 





'name':
'John
Coltrane:
A
Love
Supreme',
             db.orders.ensureIndex(
{
"line_items.sku":
1
}
);                                                   





'retail_price':
1099
                                                                                                                 



},

                                                                                                                 



{
'sku':
'ly‐211',
                                                                                                                 





'name':
'Larry
Young:
Unity',
                                                                                                                 





'retail_price':
1199
                                                                                                                 



}
                                                                                                                 

],

                                                                                                                 

'shipping_address':
{
                                                                                                                 



'street':
'3333
Greene
Ave.',
                                                                                                                 



'city':
'Brooklyn',
                                                                                                                 



'state':
'NY',
                                                                                                                 



'zip':
'11216'
                                                                                                                 

},

                                                                                                                 

'subtotal':
2199
                                                                                                                 }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
           Indexing
           On property value
             db.orders.ensureIndex(
{
"state":
1
}
);


           On embedded object property
                                                                                                                 {
'_id':
objectid('4b980a6dea2c3f4579da141e'),
             db.orders.ensureIndex(
{
"shipping_address.state":
1
}
);                                           

'user_id':
objectid('4b980a6dea2c3f4579a4f54'),
                                                                                                                 

'state':
'in_cart',

                                                                                                                 

'line_items':
[
           On embedded collections                                                                               



{
'sku':
'jc‐432',
                                                                                                                 





'name':
'John
Coltrane:
A
Love
Supreme',
             db.orders.ensureIndex(
{
"line_items.sku":
1
}
);                                                   





'retail_price':
1099
                                                                                                                 



},

                                                                                                                 



{
'sku':
'ly‐211',
           On multiple keys                                                                                      





'name':
'Larry
Young:
Unity',
                                                                                                                 





'retail_price':
1199
             db.orders.ensureIndex(
{
"shipping_address.state":
1,                                               



}
                                                                                                                 

],
             
























"subtotal":
‐1
}
);
                                                                                                                 

'shipping_address':
{
                                                                                                                 



'street':
'3333
Greene
Ave.',
                                                                                                                 



'city':
'Brooklyn',
                                                                                                                 



'state':
'NY',
                                                                                                                 



'zip':
'11216'
                                                                                                                 

},

                                                                                                                 

'subtotal':
2199
                                                                                                                 }

                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Inserting
                                                 db.orders.save(
{
                                                 



'user_name':
'Bob
Smith',
                                                 



'state':
'in_cart',

                                                 



'shipping_address':
{
                                                 





'street':
'1234
Morgan
Ave.',
                                                 





'city':
'Austin',
                                                 





'state':
'TX',
                                                 





'zip':
'78660'
                                                 



},

                                                 



'subtotal':
0
                                                 

}
);




                                                      h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Updating
                      Using Query/Modify/Save
                            var
order
=
db.orders.find(
{
'user_name':
'Bob
Smith'
}
);

                            order.state
=
'in_cart';
                            order.line_items.push(
{
'sku':
'md‐12',
                            
























'price':
2500,
                            
























'title':
'Basketball'
}
);
                            order.subtotal
=
order.subtotal
+
2500;

                            db.orders.save(
order
);




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Updating
                      Using Query/Modify/Save
                            var
order
=
db.orders.find(
{
'user_name':
'Bob
Smith'
}
);

                            order.state
=
'in_cart';
                            order.line_items.push(
{
'sku':
'md‐12',
                            
























'price':
2500,
                            
























'title':
'Basketball'
}
);
                            order.subtotal
=
order.subtotal
+
2500;

                            db.orders.save(
order
);


                           • Requires each object to be loaded in memory.
                           • Requires multiple hits to the database.
                           • Very inefficient.



                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Updating
                      Using Atomic Updates
                            db.orders.update(
{
'_id':
order_id
},
                            



{

$set:
{
'state':
'in_cart'
},
                            





$push:
{
'line_items':
{
'sku':
'md‐12',
                            






























'price':
2500,
                            






























'title':
'Basketball'
}
                            












},
                            






$inc:
{
'subtotal':
2500
}
                            



}
);




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Basic Operations
             Updating
                      Using Atomic Updates
                            db.orders.update(
{
'_id':
order_id
},
                            



{

$set:
{
'state':
'in_cart'
},
                            





$push:
{
'line_items':
{
'sku':
'md‐12',
                            






























'price':
2500,
                            






























'title':
'Basketball'
}
                            












},
                            






$inc:
{
'subtotal':
2500
}
                            



}
);



                           •    Analogous to transactions.
                           •    Requires only one trip to the database.
                           •    Operations are atomic.
                           •    Can perform multiple operations at once.



                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB System Components




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB System Components


                            mongod.exe
                           The database server




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB System Components


                            mongod.exe                                                                                    mongo.exe
                           The database server                                                                            The interactive shell




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB System Components


                            mongod.exe                                                                                    mongo.exe
                           The database server                                                                            The interactive shell




                                                                mongos.exe
                                                                The sharding router




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •   What is the NoSQL Movement?
             •   What is MongoDB?
             •   Installing
             •   Using the Mongo Shell
             •   Accessing MongoDB via REST
             •   Replication
             •   Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •   What is the NoSQL Movement?
             •   What is MongoDB?
             •   Installing
             •   Using the Mongo Shell
             •   Accessing MongoDB via REST
             •   Replication
             •   Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
Installing MongoDB
            1. Download MongoDB.                                              www.mongodb.com/downloads

            2. Extract it.
            3. Create the data folder.                                         usually /data/db -or- C:datadb

            4. Run mongod.exe




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
Installing MongoDB
            1. Download MongoDB.                                               www.mongodb.com/downloads

            2. Extract it.
            3. Create the data folder.                                          usually /data/db -or- C:datadb

            4. Run mongod.exe




                                                 That’s it!

                                                  h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •   What is the NoSQL Movement?
             •   What is MongoDB?
             •   Installing
             •   Using the Mongo Shell
             •   Accessing MongoDB via REST
             •   Replication
             •   Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •   What is the NoSQL Movement?
             •   What is MongoDB?
             •   Installing
             •   Using the Mongo Shell
             •   Accessing MongoDB via REST
             •   Replication
             •   Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
Accessing MongoDB via the Shell
            •    Inserting a document into a collection.
            •    Querying a collection.
            •    Modifying a document.
            •    Deleting a document.




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
Accessing MongoDB via the Shell
            •    Inserting a document into a collection.
            •    Querying a collection.
            •    Modifying a document.
            •    Deleting a document.



                                                  Lets do it!


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •   What is the NoSQL Movement?
             •   What is MongoDB?
             •   Installing
             •   Using the Mongo Shell
             •   Accessing MongoDB via REST
             •   Replication
             •   Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •   What is the NoSQL Movement?
             •   What is MongoDB?
             •   Installing
             •   Using the Mongo Shell
             •   Accessing MongoDB via REST
             •   Replication
             •   Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
Accessing MongoDB via REST
            • To enable basic REST interface, use --rest command line.
                     - mongod.exe --rest
            • REST interface uses port +1000.
                     - http://127.0.0.1:28017/database/collection/
                     - http://127.0.0.1:28017/database/collection/?filter&Field=Value


            • Full REST support is provided by the Sleepy.Mongoose lib.
                     - http://github.com/kchodorow/sleepy.mongoose




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •   What is the NoSQL Movement?
             •   What is MongoDB?
             •   Installing
             •   Using the Mongo Shell
             •   Accessing MongoDB via REST
             •   Replication
             •   Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Session Roadmap
             •   What is the NoSQL Movement?
             •   What is MongoDB?
             •   Installing
             •   Using the Mongo Shell
             •   Accessing MongoDB via REST
             •   Replication
             •   Sharding




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication
             Replica Sets
                     -   Full Failover support
                     -   Supports more than 2 servers in a replica cluster
                     -   Data center and rack aware
                     -   Can have passive set members (slaves) that are never primary




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     Node A
                                                                         Primary



                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                        1∆                                           Node A
                                                                         Primary



                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     Node A
                                                                         Primary
                                                             1∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary




                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     Node A
                                                                         Primary
                                                             1∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                          1∆                                                                                        1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     Node A
                                                                         Primary
                                                             1∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆                                                                                       1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                        2∆                                           Node A
                                                                         Primary
                                                             1∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆                                                                                       1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     Node A
                                                                         Primary
                                                             1∆ 2∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆                                                                                       1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     Node A
                                                                         Primary
                                                             1∆ 2∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     Node A
                                                                         Primary
                                                             1∆ 2∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                        3∆                                           Node A
                                                                         Primary
                                                             1∆ 2∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     Node A
                                                                         Primary
                                                             1∆ 2∆ 3∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     NodeiA e
                                                                          n
                                                                O ffl    Primary
                                                             1∆ 2∆ 3∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                     NodeiA e
                                                                          n
                                                                O ffl    Primary
                                                             1∆ 2∆ 3∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication
                                                                                                                                      READ
                                                                     NodeiA e
                                                                          n
                                                                                                                                      ONLY


                                                                O ffl    Primary
                                                             1∆ 2∆ 3∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication
                                                                                                                                      READ
                                                                     NodeiA e
                                                                          n
                                                                                                                                      ONLY


                                                                O ffl    Primary
                                                             1∆ 2∆ 3∆

                                  Node B                         FIGHT!                                                   Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication
                                                                                                                                      READ
                                                                     NodeiA e
                                                                          n
                                                                                                                                      ONLY


                                                                O ffl    Primary
                                                             1∆ 2∆ 3∆

                                  Node B                                   Vote                                           Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication
                                                                                                                                      READ
                                                                     NodeiA e
                                                                          n
                                                                                                                                      ONLY


                                                                O ffl    Primary
                                                             1∆ 2∆ 3∆

                                  Node B            ME!                                                Node B
                                                                                                              Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication
                                                                                                                                      READ
                                                                     NodeiA e
                                                                          n
                                                                                                                                      ONLY


                                                                O ffl    Primary
                                                             1∆ 2∆ 3∆

                                  Node B                                                                                  Node C
                                 Secondary                                                                                Secondary
                           1∆ 2∆                                                                                    1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication
                                                                                                                                      READ
                                                                                                                                      ONLY
                                                                      Node B
                                                                     Secondary
                                                             1∆ 2∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication
                                                                                                                                      READ
                                                                                                                                      ONLY
                                                                      Node B
                                                                     Secondary
                                                             1∆ 2∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                          4∆                                          Node B
                                                                          Primary
                                                             1∆ 2∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆                                     4∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆                                     4∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆                                     4∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆             4∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆                                     4∆

                                 NodeiA e
                                      n                                                                                   Node C
                             O ffl   Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆             4∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆                                     4∆

                                 Node A                                                                                   Node C
                                     Primary                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆             4∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆                                     4∆

                                 Node A                                                                                   Node C
                               Recovering...                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆             4∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆                                     4∆

                                 Node A                                                                                   Node C
                               Recovering...                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆             4∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
MongoDB Replication

                                                                      Node B
                                                                          Primary
                                                             1∆ 2∆                                     4∆

                                 Node A                                                                                   Node C
                               Recovering...                                                                              Secondary
                           1∆ 2∆ 3∆                                                                                 1∆ 2∆             4∆


                                                 h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
Introduction to MongoDB
              A No-SQL Persistence Alternative
A U S T I N - C O D E - C A M P - 2 0 1 1
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011
Introduction to MongoDB - Austin Code Camp 2011

Contenu connexe

Dernier

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Dernier (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Introduction to MongoDB - Austin Code Camp 2011

  • 1. +)1*3$&4(56&4#70&89::& !"#$%&'()&*(&+,,&-).&/0($1(.12& h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 2. h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
  • 3. Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1 Chris Edwards h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
  • 4. MongoDB h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m
  • 5. About Me Chris Edwards Architect at BancVue Ltd. Email: ChrisEdwards357@gmail.com Blog: http://chrisedwards.dreamhosters.com Twitter: @cedwards Github: http://github.com/chrisedwards (Sample code for this talk is posted) h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 6. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 7. What is No-SQL? h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 8. What is No-SQL? “Next Generation Databases mostly addressing some of the points: being non-relational, distributed, open-source and horizontal scalable. ... schema-free, easy replication support, simple API, eventually consistent ...” - nosql-database.org h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 9. What is No-SQL? “Next Generation Databases mostly addressing some of the points: being non-relational, distributed, open-source and horizontal scalable. ... schema-free, easy replication support, simple API, eventually consistent ...” - nosql-database.org • Non-Relational • Schema-Free • Distributed • Replication Support • Open-Source • Simple API • Horizontally Scalable • Eventually Consistent h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 10. What is No-SQL? It’s about using the right tool for the job. • Not all systems have the same data needs. • Sql is not the only option, nor is it always the best one. • Consider all options carefully and choose wisely. h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 11. What is No-SQL? It’s about using the right tool for the job. • Not all systems have the same data needs. • Sql is not the only option, nor is it always the best one. • Consider all options carefully and choose wisely. Not Only SQL h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 12. What is No-SQL? It’s about using the right tool for the job. • Not all systems have the same data needs. • Sql is not the only option, nor is it always the best one. • Consider all options carefully and choose wisely. Not Only SQL It’s not about flaming SQL. h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 13. What is No-SQL? It’s about using the right tool for the job. • Not all systems have the same data needs. • Sql is not the only option, nor is it always the best one. • Consider all options carefully and choose wisely. Not Only SQL It’s not about flaming SQL. Its about opening our minds to new technologies. h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 14. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 15. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 16. What is MongoDB? • Document-oriented database - Uses JSON (BSON actually) • Schema-free • Performant - Written in C++ - Full index support - No transactions (has atomic operations) “Mongo only pawn in game of life” - Memory-mapped files (delayed writes) • Replication & High Availability • Auto Sharding • Commercially supported (10gen) - Lots of documentation h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 17. Other Features of MongoDB • Document-based queries - Flexible document queries expressed in JSON/Javascript. • Map Reduce - Flexible aggregation and data processing. - Queries run in parallel on all shards. • GridFS - Store files of any size easily. • Geospatial Indexing - Find object based on location. (i.e. find closest n items to x) • Many Production Deployments h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 18. Other Features of MongoDB • Supported on Multiple Platforms - OSX - Linux - Solaris - Windows - FreeBSD h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 19. MongoDB Basic Concepts Document - Analogous to a row in RDBMS - Represented as JSON (BSON) - Hierarchical - Can reference other documents h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 20. MongoDB Basic Concepts Collection - Analogous to a table in RDBMS - Collection of documents - Documents can be anything - Advantageous if they are similar h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 21. MongoDB Basic Concepts Embedding {
'_id':
objectid('4b980a6dea2c3f4579da141e'), - Analogous to a foreign key 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', - Think “pre-joined relationship”. 

'line_items':
[ - Clearer conceptual model. 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', - DDD Aggregate Root 





'retail_price':
1099 - Can be 



}, - Sub Objects 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', - Collections 





'retail_price':
1199 



} 

], 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 22. MongoDB Basic Concepts Embedding {
'_id':
objectid('4b980a6dea2c3f4579da141e'), - Analogous to a foreign key 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', - Think “pre-joined relationship” 

'line_items':
[ - Clearer conceptual model. 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', - DDD Aggregate Root 





'retail_price':
1099 - Can be 



}, - Sub Objects 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', - Collections 





'retail_price':
1199 



} 

], 

'shipping_address':
{ References 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', - Analogous to a foreign key 



'zip':
'11216' 

}, - Think “relationship” 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 23. MongoDB Basic Operations Querying All the following queries will find the document. {
'_id':
objectid('4b980a6dea2c3f4579da141e'), 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', 

'line_items':
[ 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', 





'retail_price':
1099 



}, 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 



} 

], 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 24. MongoDB Basic Operations Querying All the following queries will find the document. By property value db.orders.find(
{
"state":
"in_cart"
}
); {
'_id':
objectid('4b980a6dea2c3f4579da141e'), 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', 

'line_items':
[ 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', 





'retail_price':
1099 



}, 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 



} 

], 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 25. MongoDB Basic Operations Querying All the following queries will find the document. By property value db.orders.find(
{
"state":
"in_cart"
}
); {
'_id':
objectid('4b980a6dea2c3f4579da141e'), By embedded object property value 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', db.orders.find(
{
"shipping_address.state":
"NY"
}
); 

'line_items':
[ 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', 





'retail_price':
1099 



}, 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 



} 

], 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 26. MongoDB Basic Operations Querying All the following queries will find the document. By property value db.orders.find(
{
"state":
"in_cart"
}
); {
'_id':
objectid('4b980a6dea2c3f4579da141e'), By embedded object property value 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', db.orders.find(
{
"shipping_address.state":
"NY"
}
); 

'line_items':
[ 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', With comparison operators 





'retail_price':
1099 



}, db.orders.find(
{
"subtotal":
{
$gt:
2000
}
}
); 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 



} 

], 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 27. MongoDB Basic Operations Querying All the following queries will find the document. By property value db.orders.find(
{
"state":
"in_cart"
}
); {
'_id':
objectid('4b980a6dea2c3f4579da141e'), By embedded object property value 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', db.orders.find(
{
"shipping_address.state":
"NY"
}
); 

'line_items':
[ 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', With comparison operators 





'retail_price':
1099 



}, db.orders.find(
{
"subtotal":
{
$gt:
2000
}
}
); 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 



} Values in collections (implicit “in”) 

], db.orders.find(
{
"line_items.sku":
"ly‐211"
}
); 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 28. MongoDB Basic Operations Indexing {
'_id':
objectid('4b980a6dea2c3f4579da141e'), 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', 

'line_items':
[ 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', 





'retail_price':
1099 



}, 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 



} 

], 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 29. MongoDB Basic Operations Indexing On property value db.orders.ensureIndex(
{
"state":
1
}
); {
'_id':
objectid('4b980a6dea2c3f4579da141e'), 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', 

'line_items':
[ 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', 





'retail_price':
1099 



}, 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 



} 

], 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 30. MongoDB Basic Operations Indexing On property value db.orders.ensureIndex(
{
"state":
1
}
); On embedded object property {
'_id':
objectid('4b980a6dea2c3f4579da141e'), db.orders.ensureIndex(
{
"shipping_address.state":
1
}
); 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', 

'line_items':
[ 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', 





'retail_price':
1099 



}, 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 



} 

], 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 31. MongoDB Basic Operations Indexing On property value db.orders.ensureIndex(
{
"state":
1
}
); On embedded object property {
'_id':
objectid('4b980a6dea2c3f4579da141e'), db.orders.ensureIndex(
{
"shipping_address.state":
1
}
); 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', 

'line_items':
[ On embedded collections 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', db.orders.ensureIndex(
{
"line_items.sku":
1
}
); 





'retail_price':
1099 



}, 



{
'sku':
'ly‐211', 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 



} 

], 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 32. MongoDB Basic Operations Indexing On property value db.orders.ensureIndex(
{
"state":
1
}
); On embedded object property {
'_id':
objectid('4b980a6dea2c3f4579da141e'), db.orders.ensureIndex(
{
"shipping_address.state":
1
}
); 

'user_id':
objectid('4b980a6dea2c3f4579a4f54'), 

'state':
'in_cart', 

'line_items':
[ On embedded collections 



{
'sku':
'jc‐432', 





'name':
'John
Coltrane:
A
Love
Supreme', db.orders.ensureIndex(
{
"line_items.sku":
1
}
); 





'retail_price':
1099 



}, 



{
'sku':
'ly‐211', On multiple keys 





'name':
'Larry
Young:
Unity', 





'retail_price':
1199 db.orders.ensureIndex(
{
"shipping_address.state":
1, 



} 

], 
























"subtotal":
‐1
}
); 

'shipping_address':
{ 



'street':
'3333
Greene
Ave.', 



'city':
'Brooklyn', 



'state':
'NY', 



'zip':
'11216' 

}, 

'subtotal':
2199 } h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 33. MongoDB Basic Operations Inserting db.orders.save(
{ 



'user_name':
'Bob
Smith', 



'state':
'in_cart', 



'shipping_address':
{ 





'street':
'1234
Morgan
Ave.', 





'city':
'Austin', 





'state':
'TX', 





'zip':
'78660' 



}, 



'subtotal':
0 

}
); h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 34. MongoDB Basic Operations Updating Using Query/Modify/Save var
order
=
db.orders.find(
{
'user_name':
'Bob
Smith'
}
); order.state
=
'in_cart'; order.line_items.push(
{
'sku':
'md‐12', 
























'price':
2500, 
























'title':
'Basketball'
}
); order.subtotal
=
order.subtotal
+
2500; db.orders.save(
order
); h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 35. MongoDB Basic Operations Updating Using Query/Modify/Save var
order
=
db.orders.find(
{
'user_name':
'Bob
Smith'
}
); order.state
=
'in_cart'; order.line_items.push(
{
'sku':
'md‐12', 
























'price':
2500, 
























'title':
'Basketball'
}
); order.subtotal
=
order.subtotal
+
2500; db.orders.save(
order
); • Requires each object to be loaded in memory. • Requires multiple hits to the database. • Very inefficient. h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 36. MongoDB Basic Operations Updating Using Atomic Updates db.orders.update(
{
'_id':
order_id
}, 



{

$set:
{
'state':
'in_cart'
}, 





$push:
{
'line_items':
{
'sku':
'md‐12', 






























'price':
2500, 






























'title':
'Basketball'
} 












}, 






$inc:
{
'subtotal':
2500
} 



}
); h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 37. MongoDB Basic Operations Updating Using Atomic Updates db.orders.update(
{
'_id':
order_id
}, 



{

$set:
{
'state':
'in_cart'
}, 





$push:
{
'line_items':
{
'sku':
'md‐12', 






























'price':
2500, 






























'title':
'Basketball'
} 












}, 






$inc:
{
'subtotal':
2500
} 



}
); • Analogous to transactions. • Requires only one trip to the database. • Operations are atomic. • Can perform multiple operations at once. h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 38. MongoDB System Components h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 39. MongoDB System Components mongod.exe The database server h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 40. MongoDB System Components mongod.exe mongo.exe The database server The interactive shell h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 41. MongoDB System Components mongod.exe mongo.exe The database server The interactive shell mongos.exe The sharding router h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 42. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 43. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 44. Installing MongoDB 1. Download MongoDB. www.mongodb.com/downloads 2. Extract it. 3. Create the data folder. usually /data/db -or- C:datadb 4. Run mongod.exe h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 45. Installing MongoDB 1. Download MongoDB. www.mongodb.com/downloads 2. Extract it. 3. Create the data folder. usually /data/db -or- C:datadb 4. Run mongod.exe That’s it! h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 46. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 47. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 48. Accessing MongoDB via the Shell • Inserting a document into a collection. • Querying a collection. • Modifying a document. • Deleting a document. h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 49. Accessing MongoDB via the Shell • Inserting a document into a collection. • Querying a collection. • Modifying a document. • Deleting a document. Lets do it! h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 50. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 51. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 52. Accessing MongoDB via REST • To enable basic REST interface, use --rest command line. - mongod.exe --rest • REST interface uses port +1000. - http://127.0.0.1:28017/database/collection/ - http://127.0.0.1:28017/database/collection/?filter&Field=Value • Full REST support is provided by the Sleepy.Mongoose lib. - http://github.com/kchodorow/sleepy.mongoose h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 53. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 54. MongoDB Session Roadmap • What is the NoSQL Movement? • What is MongoDB? • Installing • Using the Mongo Shell • Accessing MongoDB via REST • Replication • Sharding h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 55. MongoDB Replication Replica Sets - Full Failover support - Supports more than 2 servers in a replica cluster - Data center and rack aware - Can have passive set members (slaves) that are never primary h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 56. MongoDB Replication Node A Primary Node B Node C Secondary Secondary h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 57. MongoDB Replication 1∆ Node A Primary Node B Node C Secondary Secondary h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 58. MongoDB Replication Node A Primary 1∆ Node B Node C Secondary Secondary h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 59. MongoDB Replication Node A Primary 1∆ Node B Node C Secondary Secondary 1∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 60. MongoDB Replication Node A Primary 1∆ Node B Node C Secondary Secondary 1∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 61. MongoDB Replication 2∆ Node A Primary 1∆ Node B Node C Secondary Secondary 1∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 62. MongoDB Replication Node A Primary 1∆ 2∆ Node B Node C Secondary Secondary 1∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 63. MongoDB Replication Node A Primary 1∆ 2∆ Node B Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 64. MongoDB Replication Node A Primary 1∆ 2∆ Node B Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 65. MongoDB Replication 3∆ Node A Primary 1∆ 2∆ Node B Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 66. MongoDB Replication Node A Primary 1∆ 2∆ 3∆ Node B Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 67. MongoDB Replication NodeiA e n O ffl Primary 1∆ 2∆ 3∆ Node B Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 68. MongoDB Replication NodeiA e n O ffl Primary 1∆ 2∆ 3∆ Node B Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 69. MongoDB Replication READ NodeiA e n ONLY O ffl Primary 1∆ 2∆ 3∆ Node B Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 70. MongoDB Replication READ NodeiA e n ONLY O ffl Primary 1∆ 2∆ 3∆ Node B FIGHT! Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 71. MongoDB Replication READ NodeiA e n ONLY O ffl Primary 1∆ 2∆ 3∆ Node B Vote Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 72. MongoDB Replication READ NodeiA e n ONLY O ffl Primary 1∆ 2∆ 3∆ Node B ME! Node B Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 73. MongoDB Replication READ NodeiA e n ONLY O ffl Primary 1∆ 2∆ 3∆ Node B Node C Secondary Secondary 1∆ 2∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 74. MongoDB Replication READ ONLY Node B Secondary 1∆ 2∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 75. MongoDB Replication READ ONLY Node B Secondary 1∆ 2∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 76. MongoDB Replication Node B Primary 1∆ 2∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 77. MongoDB Replication Node B Primary 1∆ 2∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ 2∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 78. MongoDB Replication Node B Primary 1∆ 2∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ 2∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 79. MongoDB Replication 4∆ Node B Primary 1∆ 2∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ 2∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 80. MongoDB Replication Node B Primary 1∆ 2∆ 4∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ 2∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 81. MongoDB Replication Node B Primary 1∆ 2∆ 4∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ 2∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 82. MongoDB Replication Node B Primary 1∆ 2∆ 4∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ 2∆ 4∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 83. MongoDB Replication Node B Primary 1∆ 2∆ 4∆ NodeiA e n Node C O ffl Primary Secondary 1∆ 2∆ 3∆ 1∆ 2∆ 4∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 84. MongoDB Replication Node B Primary 1∆ 2∆ 4∆ Node A Node C Primary Secondary 1∆ 2∆ 3∆ 1∆ 2∆ 4∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 85. MongoDB Replication Node B Primary 1∆ 2∆ 4∆ Node A Node C Recovering... Secondary 1∆ 2∆ 3∆ 1∆ 2∆ 4∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 86. MongoDB Replication Node B Primary 1∆ 2∆ 4∆ Node A Node C Recovering... Secondary 1∆ 2∆ 3∆ 1∆ 2∆ 4∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1
  • 87. MongoDB Replication Node B Primary 1∆ 2∆ 4∆ Node A Node C Recovering... Secondary 1∆ 2∆ 3∆ 1∆ 2∆ 4∆ h t t p : / / c h r i s e d wa r d s . d r e a m h o s t e r s . c o m Introduction to MongoDB A No-SQL Persistence Alternative A U S T I N - C O D E - C A M P - 2 0 1 1

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. This is a test note\n
  25. \n
  26. Collection\n - Documents can be anything\n - Advantageous if they are similar\n
  27. Prejoined relationship\n
  28. Prejoined relationship\n
  29. Prejoined relationship\n
  30. Prejoined relationship\n
  31. Prejoined relationship\n
  32. Prejoined relationship\n
  33. Prejoined relationship\n
  34. Prejoined relationship\n
  35. Prejoined relationship\n
  36. Prejoined relationship\n
  37. Prejoined relationship\n
  38. Prejoined relationship\n
  39. Prejoined relationship\n
  40. Prejoined relationship\n
  41. Prejoined relationship\n
  42. Prejoined relationship\n
  43. Prejoined relationship\n
  44. Prejoined relationship\n
  45. Prejoined relationship\n
  46. Prejoined relationship\n
  47. Prejoined relationship\n
  48. Prejoined relationship\n
  49. Prejoined relationship\n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n
  146. \n
  147. \n
  148. \n
  149. \n
  150. \n
  151. \n
  152. \n
  153. \n
  154. \n
  155. \n
  156. \n
  157. \n
  158. \n
  159. \n
  160. \n
  161. \n
  162. \n
  163. \n
  164. \n
  165. \n
  166. \n
  167. \n
  168. \n
  169. \n
  170. \n
  171. \n
  172. \n
  173. \n
  174. \n
  175. \n
  176. \n
  177. \n
  178. \n
  179. \n
  180. \n
  181. \n
  182. \n
  183. \n
  184. \n
  185. \n
  186. \n
  187. \n
  188. \n
  189. \n
  190. \n
  191. \n
  192. \n
  193. \n
  194. \n
  195. \n
  196. \n
  197. \n
  198. \n
  199. \n
  200. \n
  201. \n
  202. \n
  203. \n
  204. \n
  205. \n
  206. \n
  207. \n
  208. \n
  209. \n
  210. \n
  211. \n
  212. \n
  213. \n
  214. \n
  215. \n
  216. \n
  217. \n
  218. \n
  219. \n
  220. \n
  221. \n
  222. \n
  223. \n
  224. \n
  225. \n
  226. \n
  227. \n
  228. \n
  229. \n
  230. \n
  231. \n
  232. \n
  233. \n
  234. \n
  235. \n
  236. \n
  237. \n
  238. \n
  239. \n
  240. \n
  241. \n
  242. \n
  243. \n
  244. \n
  245. \n
  246. \n
  247. \n
  248. \n
  249. \n
  250. \n
  251. \n
  252. \n
  253. \n
  254. \n
  255. \n
  256. \n
  257. \n
  258. \n
  259. \n
  260. \n
  261. \n
  262. \n
  263. \n
  264. \n
  265. \n
  266. \n
  267. \n
  268. \n
  269. \n
  270. \n
  271. \n
  272. \n
  273. \n
  274. \n
  275. \n
  276. \n
  277. \n
  278. \n
  279. \n
  280. \n
  281. \n
  282. \n
  283. \n
  284. \n
  285. \n
  286. \n
  287. \n
  288. \n
  289. \n
  290. \n
  291. \n
  292. \n
  293. \n
  294. \n
  295. \n
  296. \n
  297. \n
  298. \n
  299. \n
  300. \n