What you will hear
What is NoSQL
Available NoSQL Databases
Intro to MongoDB
Slide 3
Slide 3 text
What is NoSQL
Slide 4
Slide 4 text
Fancy Answer
NoSQL is a class of database management system identified by
its non-adherence to the widely-use relational database
management system
Slide 5
Slide 5 text
My Answer
It’s not SQL
Slide 6
Slide 6 text
Does not use SQL as its query language
May not give full ACID guarantees
Distributed architecture
Typically optimized for reading and writing operations
Slide 7
Slide 7 text
Advantages
Slide 8
Slide 8 text
Traditional Scaling
Bigger is better! (or so they thought)
Increase the size and power of the server
Slide 9
Slide 9 text
Scaling with NoSql
Scale horizontally!
Distribute across multiple servers
More economical using lower-cost servers
Slide 10
Slide 10 text
What is Sharding
Allows MongoDB to scale horizontally
Evenly distributes chunks of data
Performed per collection
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
Goodbye Schemas
Flexible data models
Easy to add/change data structures
Slide 13
Slide 13 text
Disadvantages
Slide 14
Slide 14 text
Goodbye Schemas
Flexible data structures
Application dependent on integrity
Slide 15
Slide 15 text
NoSQl is Still Young
Does not reduce administration (at least not yet)
Lack of expertise
Lack of projects expanding on NoSQL
NoSQL out in the Wild
Analytics - takes advantage of read/write optimizations
Logging
Large Scale Projects
Slide 19
Slide 19 text
MongoDB
Slide 20
Slide 20 text
What is MongoDB
Document Oriented Storage
Replication & Auto-Sharding
Document-based queries similar to SQL
Atomic Updates
Map/Reduce
Slide 21
Slide 21 text
Document Oriented
No schemas!!
No joins for high performance and scalability
embed documents
JSON-Style storage
Slide 22
Slide 22 text
High Performance
Stores a lot of data in memory
Embedding documents increase read and writes
Allows indexing
Slide 23
Slide 23 text
Availability and Scalability
Replicated servers with automatic master failover
Auto-sharing across servers
Consistent reads distributed over replicated servers
Slide 24
Slide 24 text
Atomic Modifers
In place updating documents
Does not replace entire document
Ideally suited for write heavy applications
Slide 25
Slide 25 text
Storing data
Data is grouped by collections
Collection contains documents of key-value pairs
Values can be rich including arrays and documents
Stored as BSON - Binary Serialized Document Notation
Slide 26
Slide 26 text
Querying
Javascript console allows for functions
Returns a cursor - lazy load of results
Queries expressed as JSON
Documents auto-assigned ObjectId
Slide 27
Slide 27 text
Advantages
Active community including 10Gen
Driver support for most languages
Many new features to come
Slide 28
Slide 28 text
Disadvantages
No inherit transaction support
Scaling sometimes isn’t simple
Multiple servers recommended
Object modeling can be complex
Slide 29
Slide 29 text
The big data loss debate
Internet flame war history
Mongo performs one write at a time - global lock
Stored in memory
Replication - fail over
Slide 30
Slide 30 text
Examples
Interactive time!
Goto to https://gist.github.com/2719591 for examples
Slide 31
Slide 31 text
Embed vs Referenced
Relationships for models
Object Models - Think differently
When in doubt store in different collection
Slide 32
Slide 32 text
Mongo Object Mappers for Ruby
MongoMapper
Mongoid
Mongo ODM
MongoModel
Slide 33
Slide 33 text
Mongoid Advantages
Excellent Documentation
Active Community
Compatibility with other projects
Similar API to ActiveRecord
Uses ActiveValidation
Version library
Slide 34
Slide 34 text
Compatible Gems
Devise - Authentication solutions for Rails
Carrierwave - Simple and flexible way to upload files from
Ruby. Supports GridFS
Geocoder - Complete geocoding solution for Rails
Mongoid-Rspec - RSpec matchers and macros for Mongoid
Slide 35
Slide 35 text
Mongoid Document
class Team
include Mongoid::Document
include Mongoid::Timestamps
field :name, type: String
field :city, type: String
field :location, :type => Array
validates :name, :city, :presence => true
end