How to look like a model? MongoDB for Rails apps

  • Published on
    01-Nov-2014

  • View
    249

  • Download
    0

DESCRIPTION

@muc_rubyshift 11/09/2013

Transcript

<ul><li> 1. Anna Bulenkova @povergo Software Developer @ JetBrains Brains Brains Brains Brains Brains </li></ul> <p> 2. MongoDB 3. How to look like a model? a model? 4. A long time ago in a galaxy far, far away 5. Wow! Its schema-free! Its schema-free! 6. Say bye-bye to 7. Normalization Say bye-bye to 8. Normalization Joins Say bye-bye to 9. Normalization Joins Design issues Say bye-bye to 10. Normalization Joins Design issues Transactions Say bye-bye to 11. Something wrong? 12. Document = { key -&gt; value } { key -&gt; value } { key -&gt; value } 13. Document-oriented != schema-free schema-free schema-free 14. Collection 15. BSON 16. "x16x00x00x00x02hellox 00 x06x00x00x00worldx00x 00" 17. Outside MongoDB world? 18. MongoDB Win/OS X/*nix JavaScript 19. user = { name : "Foo" } db.testData.insert(user) db.testData.find() db.testData.find() db.testData.find() 20. { "_id" : ObjectId("51a7dc7b2cacf40b79990bf7"), "name" : "Foo" } "name" : "Foo" } 21. API Aggregation Indexes Replication Sharding 22. A little bit of ActiveRecord? ActiveRecord? 23. Mongoid 24. $ gem install mongoid 25. Configuration 26. Model 27. Associations 28. Embedded 1-1 29. Embedded 1-N 30. I want my relationship back! 31. Referenced 1-1 32. Referenced 1-N 33. Referenced N-N 34. # The band document. { "_id" : ObjectId("4d3ed089fb60ab534684b7e9"), "tag_ids" : [ ObjectId("4d3ed089fb60ab534684b7f2") ] } # The tag document. { "_id" : ObjectId("4d3ed089fb60ab534684b7f2"), "band_ids" : [ ObjectId("4d3ed089fb60ab534684b7e9") ] } } } } } } } } } } } } } } 35. $gem install mongoid_rails_migrations 36. Its magical... 37. What a twist! 38. Where the hell are transactions? 39. MongoDB does not have support for traditional locking or complex transactions with rollback. MongoDB aims to be lightweight, fast, and predictable in its performance. This is similar to the MySQL MyISAM autocommit model. By keeping transaction support extremely simple, MongoDB can provide greater performance especially for partitioned or replicated systems with a number of database server processes. 40. limit 16MB 41. Global write lock 2.0pre 2.0pre 42. DB level lock 2.2 2.2 43. No joins -&gt; Many queries Many queries Many queries 44. Too many queries? -&gt; Redesign Redesign Redesign 45. Indeed schemaless? 46. Journaling 100ms 100ms 47. Data loss after replication replication replication 48. Sharding delay 49. Unencrypted traffic 50. Side effects may include... Problems working on 32-bit, large data storage problems, write falures, no error value return, sophicticated schema design, limited update operation, case sensitive queries, type sensitive fields, write locks, replica sets restrictions, unexpected data loss, sharding size limitations, no transactions, nausea, going back to RDBMS 51. Its supported in RubyMine Mine 52. Any questions? 53. Thank you! </p>