Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
Intro to MongoDB Workshop
Intro to MongoDB Workshop
Cargando en…3
×

Eche un vistazo a continuación

1 de 81 Anuncio

MongoDB: Back to Basics

Descargar para leer sin conexión

Does NoSQL feel like a bunch of NoSense to you? If so, you don’t want to miss this webinar!

In Back to Basics, we’ll teach you the fundamentals of the world’s most popular NoSQL database, MongoDB.

We'll start with a brief overview of how data is stored in MongoDB and compare that to the legacy table-based (relational) structure you may be used to. After that, we will dive deep into a demo! The demo will include:
- How to create a MongoDB database using MongoDB Atlas (for free!)
- A walk through the basic CRUD (create, read, update, and delete) operations
- Some tips and tricks for better efficiency/productivity

After this webinar, you'll be able to confidently use MongoDB to build your next app.

Does NoSQL feel like a bunch of NoSense to you? If so, you don’t want to miss this webinar!

In Back to Basics, we’ll teach you the fundamentals of the world’s most popular NoSQL database, MongoDB.

We'll start with a brief overview of how data is stored in MongoDB and compare that to the legacy table-based (relational) structure you may be used to. After that, we will dive deep into a demo! The demo will include:
- How to create a MongoDB database using MongoDB Atlas (for free!)
- A walk through the basic CRUD (create, read, update, and delete) operations
- Some tips and tricks for better efficiency/productivity

After this webinar, you'll be able to confidently use MongoDB to build your next app.

Anuncio
Anuncio

Más Contenido Relacionado

Similares a MongoDB: Back to Basics (20)

Más de Lauren Hayward Schaefer (20)

Anuncio

Más reciente (20)

MongoDB: Back to Basics

  1. 1. Back to Basics Lauren Schaefer Ken Alger @Lauren_Schaefer @KenWAlger Bonus points for following us on Twitter
  2. 2. Parks and Recreation, Season 6, Episode 14
  3. 3. Parks and Recreation, Season 6, Episode 14
  4. 4. Back to Basics Lauren Schaefer Ken Alger @Lauren_Schaefer @KenWAlger Slides are available on our Twitter pages
  5. 5. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer The story of this workshop is that it’s about MongoDB #MongoDB @KenWAlger @Lauren_Schaefer 1. MongoDB terms & concepts 2. Free MongoDB Atlas Cluster 3. CRUD operations 4. Tips & tricks 5. $100 Atlas credits
  6. 6. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer The story of this workshop is that it’s about MongoDB #MongoDB @KenWAlger @Lauren_Schaefer 1. MongoDB terms & concepts 2. Free MongoDB Atlas Cluster 3. CRUD operations 4. Tips & tricks 5. $100 Atlas credits
  7. 7. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer MongoDB stores data in documents
  8. 8. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  9. 9. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  10. 10. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  11. 11. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  12. 12. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  13. 13. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  14. 14. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  15. 15. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer MongoDB stores data in documents { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  16. 16. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] }
  17. 17. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 Users
  18. 18. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 Users ID user_id profession 10 1 banking 11 1 finance 12 1 trader Professions
  19. 19. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } ID user_id profession 10 1 banking 11 1 finance 12 1 trader Professions ID user_id model year 20 1 Bentley 1973 21 1 Rolls Royce 1965 Cars ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 Users
  20. 20. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Modeling data in MongoDB vs SQL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } ID user_id profession 10 1 banking 11 1 finance 12 1 trader Professions ID user_id model year 20 1 Bentley 1973 21 1 Rolls Royce 1965 Cars ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 Users
  21. 21. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Collections vs Tables { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } { first_name: ”Lauren", surname: ”Schaefer", cell: ”1235552222", city: ”Lancaster", profession: [”software engineer", ”developer advocate"], } { first_name: ”Sydney", surname: ”Schaefer", city: ”Lancaster", school: ”Daisy’s Daycare” } ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 2 Lauren Schaefer 1235552222 Lancaster NULL NULL 3 Sydney Schaefer NULL Lancaster NULL NULL UsersUsers
  22. 22. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 2 Lauren Schaefer 1235552222 Lancaster NULL NULL 3 Sydney Schaefer NULL Lancaster NULL NULL Collections vs Tables { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } { first_name: ”Lauren", surname: ”Schaefer", cell: ”1235552222", city: ”Lancaster", profession: [”software engineer", ”developer advocate"], } { first_name: ”Sydney", surname: ”Schaefer", city: ”Lancaster", school: ”Daisy’s Daycare” } UsersUsers
  23. 23. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Collections vs Tables ID first_name surname cell city location_x location_y 1 Paul Miller 447557505611 London 45.123 47.232 2 Lauren Schaefer 1235552222 Lancaster NULL NULL 3 Sydney Schaefer NULL Lancaster NULL NULL { first_name: "Paul", surname: "Miller", cell: "447557505611", city: "London", location: [45.123,47.232], profession: ["banking", "finance", "trader"], cars: [ { model: "Bentley", year: 1973 }, { model: "Rolls Royce", year: 1965 } ] } { first_name: ”Lauren", surname: ”Schaefer", cell: ”1235552222", city: ”Lancaster", profession: [”software engineer", ”developer advocate"], } { first_name: ”Sydney", surname: ”Schaefer", city: ”Lancaster", school: ”Daisy’s Daycare” } UsersUsers
  24. 24. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Flexible Schema
  25. 25. Don’t panic! Use schema validation. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Flexible Schema
  26. 26. Document Row { ... a: “b” ... } ID a ... 1 b ... 2 ... ... 3 ... ... #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer
  27. 27. Document Row(s) { ... a: “b” ... } ID a ... 1 b ... 2 ... ... 3 ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer
  28. 28. Field Column ID a ... 1 b ... 2 c ... 3 ... ... { ... a: “b” ... } { ... a: “c” ... } #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  29. 29. Collection Table { ... } ... ... ... ... ... ... ... ... ... ... ... ... { ... } { ... } #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  30. 30. Database Database ... ... ... ... ... ... ... ... ... ... ... ... { ... } { ... } { ... } { ... } { ... } { ... } { ... } ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  31. 31. Index Index { ... } { ... } { ... } { ... } ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  32. 32. View View { ... } ... ... ... ... ... ... ... ... ... ... ... ... { ... } { ... } #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  33. 33. Embedding Join { ... a: “b”, ... c: { d: “e” ... }, ... } ID a ... 1 b ... 2 ... ... 3 ... ... ... d ... 1 e ... ... ... ... #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  34. 34. Database References Join ID ... ... 1 ... ... 2 ... ... 3 ... ... ... ... ... 1 ... ... ... ... ... { ... } { ... } { ... } { ... } { ... } { ... } { ... } #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  35. 35. $lookup (Aggregation Pipeline) Left Outer Join ID ... ... 1 ... ... 2 ... ... 3 ... ... ... ... ... 1 ... ... 4 ... ... { ... } { ... } { ... } { ... } { ... } { ... } { ... } #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  36. 36. $graphLookup (Aggregation Pipeline) Recursive Common Table Expressions { ... } ... ... ... ... ... ... ... ... ... ... ... ... { ... } { ... } #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  37. 37. Multi-Document ACID Transaction Multi-Record ACID Transaction { ... } { ... } { ... } { ... } { ... } { ... } { ... } ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  38. 38. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Term mapping summary x Row Column Table Database Index Join Join Left Outer Join Recursive Common Table Expressions View Transaction Document Field Collection Database Index Embedding Database References $lookup $graphLookup View Transaction
  39. 39. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer The story of this workshop is that it’s about MongoDB 1. MongoDB terms & concepts 2. Free MongoDB Atlas Cluster 3. CRUD operations 4. Tips & tricks 5. $100 Atlas credits
  40. 40. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer The story of this workshop is that it’s about MongoDB 1. MongoDB terms & concepts 2. Free MongoDB Atlas Cluster 3. CRUD operations 4. Tips & tricks 5. $100 Atlas credits
  41. 41. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer The story of this workshop is that it’s about MongoDB 1. MongoDB terms & concepts 2. Free MongoDB Atlas Cluster 3. CRUD operations 4. Tips & tricks 5. $100 Atlas credits
  42. 42. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Use Indexes for Read Speed • Very important for reads. • However, they come with overhead. • New in MongoDB 4.2, Wildcard Indexes
  43. 43. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Indexes support the efficient execution of queries in MongoDB. Use Indexes for Read Speed
  44. 44. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Index Types in MongoDB Single Field { karma: 1} Compound Field { karma: 1, user_id: -1 } Multikey { “address.postal_code”: 1 } Geospatial Text Hashed Wildcard
  45. 45. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Model Data Using Schema Design Patterns • Different way of modeling from the legacy database paradigm. • Schema Design is important.
  46. 46. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Why Do We Create Models? Ensure: • Good performance • Scalability despite constraints Hardware • RAM faster than Disk • Disk cheaper than RAM • Network latency • Reduce costs $$$ Database Server • Maximum size for a document Data set • Size of data
  47. 47. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer • Frequency of Access • Subset • Approximation • Extended Reference Patterns by Category • Grouping • Computed • Bucket • Outlier • Representation • Attribute • Schema Versioning • Document Versioning • Tree • Polymorphism • Pre-Allocation
  48. 48. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Add a field to track the schema version number, per document Does not have to exist for version 1 Pattern: Schema Versioning
  49. 49. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Problem: Updating the schema of a database is: • Not atomic • Long operation • May not want to update all documents, only do it on updates Schema Versioning Pattern Use cases: Practically any database that will go to production
  50. 50. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Solution: Have a field keeping track of the schema version Schema Versioning Pattern – Solution Benefits: Don't need to update all the documents at once May not have to update documents until their next modification
  51. 51. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Reduce Aggravations with the Aggregation Framework • Use whenever possible • Operations are done server-side • Order of stages matters
  52. 52. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Aggregation
  53. 53. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer PIPELINE ps ax | grep mongod| head 1 *nix command line pipe
  54. 54. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer PIPELINE $match $group | $sort| Input stream {} {} {} {} Result {} {} ... MongoDB document pipeline
  55. 55. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer The story of this workshop is that it’s about MongoDB 1. MongoDB terms & concepts 2. Free MongoDB Atlas Cluster 3. CRUD operations 4. Tips & tricks 5. $100 Atlas credits
  56. 56. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Sign up for MongoDB Atlas http://bit.ly/MDB_Atlas
  57. 57. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Add discount code: BACKTOBASICS2020
  58. 58. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Add discount code: BACKTOBASICS2020
  59. 59. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Add discount code: BACKTOBASICS2020
  60. 60. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer The story of this workshop is that it’s about MongoDB 1. MongoDB terms & concepts 2. Free MongoDB Atlas Cluster 3. CRUD operations 4. Tips & tricks 5. $100 Atlas credits
  61. 61. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer 1. Map terms from SQL to MongoDB x Row Column Table Database Index Join Join Left Outer Join Recursive Common Table Expressions View Transaction Document Field Collection Database Index Embedding Database References $lookup $graphLookup View Transaction
  62. 62. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer 2. Free Atlas cluster
  63. 63. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer 3. The CRUD operations
  64. 64. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer 4. Tips & tricks • Use Indexes for Read Speed • Model Data Using Schema Design Patterns • Reduce Aggravation with the Aggregation Pipeline
  65. 65. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer 5. $100 Atlas credits with code: BACKTOBASICS2020
  66. 66. Don’t be Ron Swanson (in this particular case) #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  67. 67. Change your mindset & get the full value of MongoDB Don’t be Ron Swanson #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics
  68. 68. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Additional resources on data modeling patterns • Advanced Schema Design Patterns (webinar) • Building with Patterns: A Summary (blog series) • M320: Data Modeling (MongoDB University Course – brand new!)
  69. 69. #BackToBasics #MongoDB @KenWAlger @Lauren_Schaefer Additional resources • The MongoDB Docs • Quick Start blog series in a variety of programming languages • JSON Schema Validation – Locking down your model the smart way • JSON Schema Validation - Checking Your Arrays • M121: The MongoDB Aggregation Framework
  70. 70. Don’t be Ron Swanson (in this particular case) Change your mindset and get the full value of MongoDB Change your mindset & get the full value of MongoDB Get the slides on our Twitter pages: @KenWAlger @Lauren_Schaefer #MongoDB @KenWAlger @Lauren_Schaefer#BackToBasics

×