MongoDB for the SQL Server Pro
What is MongoDB?
• Open source NoSQL database
• Document-oriented
• Stores JSON-like documents (dynamic schemas)
• Include...
QUICKSTART - SETUP MONGODB
Demo
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
COMPARING DOCUMENT
DATABASES TO RDBMS SYSTEMS
Understanding more..
So which type of NoSQL? CAP…
Consistency
Availability
Partition
Tolerance
CP = noSQL/column
Hadoop
Big Table
H-base
MemCac...
DB Features for MongoDB & SQL Server
primary keys
and indexes
queries with
models for
sorting /
limiting results
a strong
...
DB Features unique to Document DBs
Collections, not Tables
Query language, not T-SQL
Idrefs, not Joins
No pre-defined Sche...
Use 10gen Quick Reference Cards
DB Features of note in MongoDB
• BSON supports more complex types (date, geo-spatial, etc…)
• Supports dynamic queries via...
Why use MongoDB?
• Document-like
• Semi-structured
• Few Joins
• Geospatial
Data Structure
• Large or Huge
• Distributed
•...
MongoDB Scenarios
Document
Management
systems
E-commerce
(catalog portion
only)
Archiving /
event logging
Real time
analyt...
IMPORTING DATA TO MONGODB
Demo
Adding Data
• Data must be in JSON format - converter
• “Insert” CREATES a collection if needed
Importing data…using MongoVue
Viewing Collection Data
USING VELOCITY FOR MODELING
Demo
Modeling
Use short names
• each name is saved for
each document
• can save up to 30%
storage
Keep collections
small
• Can ...
Comparing…
QUERY MONGODB DATA
Demo
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?
No
traditional
joins in
MongoDB
Can use
Arrays
Can use
Embedded
Documents
Can use
DBRef
Can De-
normaliz...
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 specif...
Understanding Explain
• Query execution detail plan
• Review number of scanned objects
ADD INDEXES TO MONGODB
Understanding more
Modifying Data
Update
• alone does a replace
Update w/ $set
• does an update
Update w/ $inc
• increments
Upserts
• must be...
Using Update
USING GRIDFS
Understanding more…
What is GridFS?
• Used to hold objects larger than 16 MB
CONNECTING TO MONGODB WITH C#
Demo
Programming against MongoDB
More Information
• MongoDB
– http://www.mongodb.org
• 10gen
– http://www.10gen.com/contact
– info@10gen.com
• YouTube vide...
The Changing Data Landscape
NoSQL
RDBMS
Other
Services
Upcoming SlideShare
Loading in …5
×

MongoDB for the SQL Server

713 views

Published on

MongoDB for the SQL Server

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

  • Be the first to like this

No Downloads
Views
Total views
713
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Source - http://www.10gen.com/what-is-mongodb
  • https://www.youtube.com/watch?v=k2YFy5IQu1M
  • http://www.mongodb.org/downloads
    https://github.com/mongodb/mongo-csharp-driver/downloads
  • http://www.mongovue.com/
  • http://amitpiplani.blogspot.com/2010/05/u-pick-2-selection-for-nosql-providers.html

  • http://docs.mongodb.org/manual/faq/developers/#how-do-i-do-transactions-and-locking-in-mongodb
  • http://www.10gen.com/reference
  • http://www.mongodb.org/display/DOCS/Use+Cases
  • http://www.mongodb.org/display/DOCS/Use+Cases
  • Free conversion (CSV to JSON) - http://www.cparker15.com/code/utilities/csv-to-json/
  • http://rickosborne.org/download/SQL-to-MongoDB.pdf
  • http://www.mongovue.com/2010/06/29/find/
  • 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://www.mongovue.com/2010/09/14/updating-collections/
  • 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#10645816
    Default chunk size is 256kb

    Db.fs.files
    Fs.chunk
    Upload.date.date()
  • https://www.youtube.com/watch?v=NCp4n6xWw68
  • http://www.youtube.com/watch?v=NCp4n6xWw68
  • MongoDB for the SQL Server

    1. 1. MongoDB for the SQL Server Pro
    2. 2. 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 )
    3. 3. QUICKSTART - SETUP MONGODB Demo
    4. 4. Get MongoDB and Driver(s) • Quick download, zero install • Also get your driver (C# for us)
    5. 5. Starting up MongoDB
    6. 6. Using the Console
    7. 7. Using MongoVue
    8. 8. Connecting with MongoVue
    9. 9. Using MongoVue
    10. 10. COMPARING DOCUMENT DATABASES TO RDBMS SYSTEMS Understanding more..
    11. 11. So which type of NoSQL? CAP… Consistency Availability Partition Tolerance CP = noSQL/column Hadoop Big Table H-base MemCacheDB (graph)? CA = SQL/RDBMS SQL Sever / SQL Azure Oracle MySQL AP = noSQL/document or key/value MongoDB DynamoDB CouchDB Cassandra Voldemort
    12. 12. DB Features for MongoDB & SQL Server primary keys and indexes queries with models for sorting / limiting results a strong typing system aggregations like SUM(), COUNT(), etc… Large object support
    13. 13. DB Features unique to Document DBs Collections, not Tables Query language, not T-SQL Idrefs, not Joins No pre-defined Schema • Aggregation Framework • Grouping or MapReduce Aggregations • No multi-document transactions No Transactions No Full-text search
    14. 14. Use 10gen Quick Reference Cards
    15. 15. 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
    16. 16. Why use MongoDB? • Document-like • Semi-structured • Few Joins • Geospatial Data Structure • Large or Huge • Distributed • Unpredictable Data Volume
    17. 17. MongoDB Scenarios Document Management systems E-commerce (catalog portion only) Archiving / event logging Real time analytics (based on logging) Gaming Geospatial Mobile
    18. 18. IMPORTING DATA TO MONGODB Demo
    19. 19. Adding Data • Data must be in JSON format - converter • “Insert” CREATES a collection if needed
    20. 20. Importing data…using MongoVue
    21. 21. Viewing Collection Data
    22. 22. USING VELOCITY FOR MODELING Demo
    23. 23. Modeling Use short names • each name is saved for each document • can save up to 30% storage Keep collections small • Can create non- default (narrower) key • Document size maximum is 4 MB Use GridFS for BLOBs
    24. 24. Comparing…
    25. 25. QUERY MONGODB DATA Demo
    26. 26. Using Find Find, Fields, Sort, Count, Skip, Limit, Visualize or Export
    27. 27. Data Visualization
    28. 28. Queries
    29. 29. Queries 2 …
    30. 30. Queries 3…
    31. 31. What is Grouping? • Similar to T-SQL ‘Group By’ • Written in javascript
    32. 32. What about Joins? No traditional joins in MongoDB Can use Arrays Can use Embedded Documents Can use DBRef Can De- normalize schema
    33. 33. About the Aggregation Framework • New in MongoDB 2.2 • Layer on top to facilitate easier query-writing
    34. 34. 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
    35. 35. Understanding Explain • Query execution detail plan • Review number of scanned objects
    36. 36. ADD INDEXES TO MONGODB Understanding more
    37. 37. Modifying Data Update • alone does a replace Update w/ $set • does an update Update w/ $inc • increments Upserts • must be enabled • then insert if new, update if existing Multiple field updates • occur by default
    38. 38. Using Update
    39. 39. USING GRIDFS Understanding more…
    40. 40. What is GridFS? • Used to hold objects larger than 16 MB
    41. 41. CONNECTING TO MONGODB WITH C# Demo
    42. 42. Programming against MongoDB
    43. 43. 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
    44. 44. The Changing Data Landscape NoSQL RDBMS Other Services

    ×