Your SlideShare is downloading. ×
0
Hands On Lynn Langit               April 2013 – for BigData Tech Con – Boston, MA
Data Expertise / Lynn Langit• Industry awards   – Microsoft – MVP for SQL Server   – Google – GDE for Cloud Platform   – 1...
What is MongoDB?                                            Stores JSON-like Open source           Document-              ...
DemoONLINE TUTORIAL - TRY IT OUT
Get MongoDB and Driver(s)• Quick download, zero install• Also get your driver (C# for us)
Use 10gen Quick Reference Cards
DemoQUICKSTART - SETUP MONGODB
Starting up MongoDB
Using the console
Demo -- Using MongoVue
Understanding MongoVue
MongoDB in the Cloud - MongoLab
Adding Data• Data must be in JSON format - converter• “Insert” CREATES a collection if needed
DemoADDING DATA TO MONGODB
Importing data…using MongoVue
Viewing Collection Data
DemoQUERY MONGODB DATA
Using FindFind, Fields, Sort, Count, Skip, Limit, Visualize or Export
Comparing…
Simple Query Translations
More Query Translations
What is Grouping?• Similar to T-SQL ‘Group By’• Written in javascript
About the Aggregation Framework• New in MongoDB 2.2• Layer on top to facilitate easier query-writing
MapReduce in MongoDB                Map                      Reduce            Optional Post-                • Transforms ...
Using MapReduce• Example: find the 2 closest cities in each  country, except in United States• Using SQL Server (T-SQL) vs...
MapReduce in MongoVue - I
MapReduce in MongoVue - II
DemoMAPREDUCE IN MONGODB
What is GridFS?• Used to hold objects larger than 4 MB
DemoUSING GRIDFS
Data Visualization
Modifying DataUpdate                       Update w/ $set             Update w/ $inc• alone does a replace       • does an...
Update Query Translations
Using Update
Modeling                                                  Use GridFS for                                                  ...
What about Joins?               Can use                Arrays                No Can De-normalize            traditional   ...
Understanding Explain• Query execution detail plan• Review number of scanned objects
DemoADD INDEXES TO MONGODB
Index Tuning Best Practices                  • Non _id                  • Add columns to index (specificity) Create best  ...
DemoCONNECTING TO MONGODB WITHC#
Programming against MongoDB
DB Features for MongoDB & SQL Serverprimary keys and indexes   queries with models for sorting / limiting   results       ...
DB Features unique to Document DBs     Collections        • not Tables   Query language       • not T-SQL       Idrefs    ...
DB Features of note in MongoDB• BSON supports more complex types (date, geo-spatial, etc…)• Supports dynamic queries via p...
Why use MongoDB?Data Structure•   Document-like•   Semi-structured•   Few Joins•   GeospatialData Volume• Large or Huge• D...
MongoDB Scenarios  Document           E-commerce                                       Archiving / Management        (cata...
More Information• MongoDB   – http://www.mongodb.org• 10gen   – http://www.10gen.com/contact   – info@10gen.com• YouTube v...
The Changing Data Landscape                               Other                              ServicesRDBMS          NoSQL
• recipes)www.TeachingKidsProgramming.org•   Free Courseware (•   Do a Recipe  Teach a Kid (Ages 10 ++)•   Java or Micros...
Toward Data Craftsmanship…                Follow me @LynnLangit                     RSS my blog                  www.LynnL...
Upcoming SlideShare
Loading in...5
×

HandsOn MongoDB

4,819

Published on

deck from

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,819
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
123
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide
  • Source - http://www.10gen.com/what-is-mongodb
  • http://www.mongodb.org/downloadshttps://github.com/mongodb/mongo-csharp-driver/downloads
  • http://www.10gen.com/reference
  • https://www.youtube.com/watch?v=k2YFy5IQu1M
  • http://www.mongovue.com/
  • Free conversion (CSV to JSON) - http://www.cparker15.com/code/utilities/csv-to-json/
  • http://www.mongovue.com/2010/06/29/find/
  • http://rickosborne.org/download/SQL-to-MongoDB.pdf
  • http://api.mongodb.org/wiki/current/Aggregation.html
  • http://docs.mongodb.org/manual/aggregation/And http://docs.mongodb.org/manual/reference/sql-aggregation-comparison/
  • http://blog.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/
  • http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/Link to download source data - http://www.geobytes.com/freeservices.htm
  • 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()
  • http://www.mongovue.com/2010/09/14/updating-collections/
  • https://www.youtube.com/watch?v=NCp4n6xWw68
  • http://www.youtube.com/watch?v=NCp4n6xWw68
  • http://docs.mongodb.org/manual/faq/developers/#how-do-i-do-transactions-and-locking-in-mongodb
  • http://www.mongodb.org/display/DOCS/Use+Cases
  • http://www.mongodb.org/display/DOCS/Use+Cases
  • Lynn
  • Transcript of "HandsOn MongoDB"

    1. 1. Hands On Lynn Langit April 2013 – for BigData Tech Con – Boston, MA
    2. 2. Data Expertise / Lynn Langit• Industry awards – Microsoft – MVP for SQL Server – Google – GDE for Cloud Platform – 10Gen – Master for MongoDB• Practicing Architect• Technical author / trainer – Pluralsight – Google Cloud Series – DevelopMentor – SQL Server Series – 2 books on SQL Server BI• Former MSFT FTE – 4 years
    3. 3. What is MongoDB? Stores JSON-like Open source Document- documentsNoSQL database oriented (dynamic schemas)Includes a strong Powerful, flexible Sharding and query language indexing (including replication (javascript) geospatial) Cross-Platform (many drivers )
    4. 4. DemoONLINE TUTORIAL - TRY IT OUT
    5. 5. Get MongoDB and Driver(s)• Quick download, zero install• Also get your driver (C# for us)
    6. 6. Use 10gen Quick Reference Cards
    7. 7. DemoQUICKSTART - SETUP MONGODB
    8. 8. Starting up MongoDB
    9. 9. Using the console
    10. 10. Demo -- Using MongoVue
    11. 11. Understanding MongoVue
    12. 12. MongoDB in the Cloud - MongoLab
    13. 13. Adding Data• Data must be in JSON format - converter• “Insert” CREATES a collection if needed
    14. 14. DemoADDING DATA TO MONGODB
    15. 15. Importing data…using MongoVue
    16. 16. Viewing Collection Data
    17. 17. DemoQUERY MONGODB DATA
    18. 18. Using FindFind, Fields, Sort, Count, Skip, Limit, Visualize or Export
    19. 19. Comparing…
    20. 20. Simple Query Translations
    21. 21. More Query Translations
    22. 22. What is Grouping?• Similar to T-SQL ‘Group By’• Written in javascript
    23. 23. About the Aggregation Framework• New in MongoDB 2.2• Layer on top to facilitate easier query-writing
    24. 24. MapReduce in MongoDB Map Reduce Optional Post- • Transforms input • Transform ProcessingOptional Pre- and emits key => key/values to • Finalize Processing value pairs output via • Filters • These K/V pairs will aggregation be reduced
    25. 25. Using MapReduce• Example: find the 2 closest cities in each country, except in United States• Using SQL Server (T-SQL) vs.• Using MongoDB (MapReduce in JavaScript)
    26. 26. MapReduce in MongoVue - I
    27. 27. MapReduce in MongoVue - II
    28. 28. DemoMAPREDUCE IN MONGODB
    29. 29. What is GridFS?• Used to hold objects larger than 4 MB
    30. 30. DemoUSING GRIDFS
    31. 31. Data Visualization
    32. 32. Modifying DataUpdate 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
    33. 33. Update Query Translations
    34. 34. Using Update
    35. 35. Modeling Use GridFS for BLOBs Keep collections smallUse short names • Can create non- default (narrower) key• each name is saved • Document size for each document maximum is 16 MB• can save up to 30% storage
    36. 36. What about Joins? Can use Arrays No Can De-normalize traditional Can use Embedded schema joins in Documents MongoDB Can use DBRef
    37. 37. Understanding Explain• Query execution detail plan• Review number of scanned objects
    38. 38. DemoADD INDEXES TO MONGODB
    39. 39. Index Tuning Best Practices • Non _id • Add columns to index (specificity) Create best indexes • Multiple columns, most specific first • Based on query workloads Test newindexes for use
    40. 40. DemoCONNECTING TO MONGODB WITHC#
    41. 41. Programming against MongoDB
    42. 42. DB Features for MongoDB & SQL Serverprimary keys and indexes queries with models for sorting / limiting results a strong typing system aggregations like SUM(), COUNT(), etc… Geospatial or Text search
    43. 43. DB Features unique to Document DBs Collections • not Tables Query language • not T-SQL Idrefs • not JoinsNo pre-defined Schema • Nesting is common • Aggregation Framework Aggregations • Grouping or MapReduce • Within same document Transactions • No multi-document transactions
    44. 44. 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• Role-based and Kerberos Security• Scalability via Replication/Sharding – including hashed sharding
    45. 45. Why use MongoDB?Data Structure• Document-like• Semi-structured• Few Joins• GeospatialData Volume• Large or Huge• Distributed• Unpredictable
    46. 46. MongoDB Scenarios Document E-commerce Archiving / Management (catalog portion event logging systems only) Real timeanalytics (based Gaming Geospatial on logging) Mobile
    47. 47. 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
    48. 48. The Changing Data Landscape Other ServicesRDBMS NoSQL
    49. 49. • recipes)www.TeachingKidsProgramming.org• Free Courseware (• Do a Recipe  Teach a Kid (Ages 10 ++)• Java or Microsoft SmallBasic 
    50. 50. 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
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×