SlideShare una empresa de Scribd logo
1 de 46
MongoDB for the SQL Server Pro



            Lynn Langit


                           Feb 2013 – For MongoDB LA
What is MongoDB?
•   Open source NoSQL database
•   Document-oriented
•   Stores JSON-like documents (dynamic schemas)
•   Includes a strong query language (javascript)
•   Powerful, flexible indexing (including geospatial)
•   Sharding and replication
•   Cross-Platform (many drivers )
Demo

QUICKSTART - SETUP MONGODB
Get MongoDB and Driver(s)
• Quick download, zero install
• Also get your driver (C# for us)
Starting up MongoDB
Using the Console
Using MongoVue
Connecting with MongoVue
Using MongoVue
Understanding more..

COMPARING DOCUMENT
DATABASES TO RDBMS SYSTEMS
So which type of NoSQL? CAP…
                                                      CA = SQL/RDBMS
CP = noSQL/column
                                                      SQL Sever / SQL
Hadoop
                                                      Azure
Big Table
                                                      Oracle
H-base
                                                      MySQL
MemCacheDB
(graph)?            Consistency
                                       Availability


                                                AP = noSQL/document
                                                or key/value
                           Partition            MongoDB
                                                DynamoDB
                          Tolerance             CouchDB
                                                Cassandra
                                                Voldemort
DB Features for MongoDB & SQL Server


               Large object        primary keys
                 support           and indexes



          aggregations                     queries with
               like                         models for
         SUM(), COUNT                        sorting /
            (), etc…                     limiting results


                            a strong
                         typing system
DB Features unique to Document DBs
 Collections, not Tables


 Query language, not T-SQL


 Idrefs, not Joins


 No pre-defined Schema


 Aggregations

 • Aggregation Framework
 • Grouping or MapReduce

 No Transactions

 • No multi-document transactions

 No Full-text search
Use 10gen Quick Reference Cards
DB Features of note in MongoDB
• BSON supports more complex types (date, geo-spatial, etc…)
• Supports dynamic queries via proprietary query language
   – Uses “find()” which returns a *lazy+ cursor
   – Multi-key indexes can be created
• Scalability via Replication and Sharding
Why use MongoDB?
Data Structure

• Document-like
• Semi-structured
• Few Joins
• Geospatial

Data Volume

• Large or Huge
• Distributed
• Unpredictable
MongoDB Scenarios
  Document           E-commerce
                                       Archiving /
 Management        (catalog portion
                                      event logging
   systems               only)

   Real time
analytics (based       Gaming          Geospatial
  on logging)


                       Mobile
Demo

IMPORTING DATA TO MONGODB
Adding Data
• Data must be in JSON format - converter
• “Insert” CREATES a collection if needed
Importing data…using MongoVue
Viewing Collection Data
Demo

USING VELOCITY FOR MODELING
Modeling

                                                      Use GridFS for
                                                      BLOBs
                           Keep collections
                           small
Use short names            • Can create non-
                             default (narrower) key
• each name is saved for
                           • Document size
  each document
                             maximum is 4 MB
• can save up to 30%
  storage
Comparing…
Demo

QUERY MONGODB DATA
Using Find
Find, Fields, Sort, Count, Skip, Limit, Visualize or Export
Data Visualization
Queries
Queries 2 …
Queries 3…
What is Grouping?
• Similar to T-SQL ‘Group By’
• Written in javascript
What about Joins?

               Can use
                Arrays




                No
 Can De-
normalize
            traditional    Can use
                          Embedded
 schema       joins in    Documents

            MongoDB

               Can use
                DBRef
About the Aggregation Framework
• New in MongoDB 2.2
• Layer on top to facilitate easier query-writing
Query Tuning
• Use best indexes
  – Evaluate use of _id
  – Add columns to index (specificity)
  – Multiple columns, most specific first
  – Can use fully covered indexing (indexOnly:true)
  – Test to make sure indexes are being used
• Qty scanned s/b same as QTY returned
• Use .explain
Understanding Explain
• Query execution detail plan
• Review number of scanned objects
Understanding more

ADD INDEXES TO MONGODB
Modifying Data

Update                       Update w/ $set             Update w/ $inc
• alone does a replace       • does an update           • increments




              Upserts                     Multiple field
              • must be enabled           updates
              • then insert if            • occur by default
                new, update if existing
Using Update
Understanding more…

USING GRIDFS
What is GridFS?
• Used to hold objects larger than 16 MB
Demo

CONNECTING TO MONGODB WITH C#
Programming against MongoDB
More Information
• MongoDB
   – http://www.mongodb.org
• 10gen
   – http://www.10gen.com/contact
   – info@10gen.com
• YouTube videos (from Lynn Langit)
   – MongoDB Playlist -
     https://www.youtube.com/playlist?list=PLCE5902FB1D284880
     &feature=view_all
• MongoDB LA UG - http://www.meetup.com/Los-Angeles-
  MongoDB-User-Group
The Changing Data Landscape

                             Other
                            Services
RDBMS
           NoSQL
• recipes)




www.TeachingKidsProgramming.org
•   Free Courseware (
•   Do a Recipe  Teach a Kid (Ages 10 ++)
•   Java or Microsoft SmallBasic 
Toward Data Craftsmanship…

                 Follow me @LynnLangit



                      RSS my blog
                   www.LynnLangit.com


            Hire me
            • To help build your BI/Big Data solution
            • To teach your team next gen BI
            • To learn more about using NoSQL
              solutions

Más contenido relacionado

Más de MongoDB

Más de MongoDB (20)

MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDBMongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
 
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...
 
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
 
MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...
MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...
MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...
 

MongoDB for the SQL Server Pro

Notas del editor

  1. Source - http://www.10gen.com/what-is-mongodb
  2. https://www.youtube.com/watch?v=k2YFy5IQu1M
  3. http://www.mongodb.org/downloadshttps://github.com/mongodb/mongo-csharp-driver/downloads
  4. http://www.mongovue.com/
  5. http://amitpiplani.blogspot.com/2010/05/u-pick-2-selection-for-nosql-providers.html
  6. http://docs.mongodb.org/manual/faq/developers/#how-do-i-do-transactions-and-locking-in-mongodb
  7. http://www.10gen.com/reference
  8. http://www.mongodb.org/display/DOCS/Use+Cases
  9. http://www.mongodb.org/display/DOCS/Use+Cases
  10. Free conversion (CSV to JSON) - http://www.cparker15.com/code/utilities/csv-to-json/
  11. http://rickosborne.org/download/SQL-to-MongoDB.pdf
  12. http://www.mongovue.com/2010/06/29/find/
  13. http://api.mongodb.org/wiki/current/Aggregation.html
  14. http://docs.mongodb.org/manual/aggregation/And http://docs.mongodb.org/manual/reference/sql-aggregation-comparison/
  15. http://www.mongovue.com/2010/09/14/updating-collections/
  16. http://learnmongo.com/posts/getting-started-with-mongodb-gridfs/Example: http://stackoverflow.com/questions/4988436/mongodb-gridfs-with-c-how-to-store-files-such-as-images/10645816#10645816Default chunk size is 256kbDb.fs.filesFs.chunkUpload.date.date()
  17. https://www.youtube.com/watch?v=NCp4n6xWw68
  18. http://www.youtube.com/watch?v=NCp4n6xWw68
  19. Lynn