SlideShare a Scribd company logo
NOSQL
agile data storage
SQL: THE BEGINNING
• Data structured on tables
 using columns

• Data on one column is the
 key for making relationships
 with other tables

• Normalization

• RDBMS
SQL EXAMPLES
RDBMS BENEFITS
• Normalization  (a common
 standard format for
 accessing data)

• Data   consistency

• Persistence

• Consistency

• Replication
RDBMS PROBLEMS
RDBMS PROBLEMS
• Highcost on performing
 complex operations over a
 big database

• High
     system load: scalability
 needs

• Difficult   failover recovery

• Difficult   denormalization
NOSQL TO THE RESCUE!
NOSQL IS...
•A  storage system for format
 free data

• Web   scale

• Software    darwinism

• Different
          types of solutions
 depending on the needs:
 Key-value, Documents,
 Graphs, Objects...
REDIS
• http://redis.io               Redis is SEXY

• Key-value    store

• In   memory

• Persistent
          (periodical
 asynchronous writes to disk)

• All   operations are atomic
REDIS
Types of data          Cool operations
• Hashes
                       • RPOPLPUSH
• Sets    (arrays)
                       • Pub/Sub
• Lists
REDIS
HSET myuser “email” “ivan@ivanhq.net”
HSET myuser “web” “http://ibelmonte.com”
HSET myuser “blog” “http://ivanh.net”

HGET myuser “email”
- ivan@ivanhq.net
REDIS
sadd myuser:books “jackass”
sadd myuser:books “jackass2”
sadd myuser:books “Dude, where’s my car?”
sadd myuser:books “The hangover”

smembers myuser:books
1. jackass
2. jackass2
3. Dude, where’s my car?
4. The hangover
REDIS

rpush friends “John Doe”
rpush friends “Foo”
rpush friends “Bar”

lrange friends 0 -1
1. John Doe
2. Foo
3. Bar
REDIS

rpush nonfriends “Peter Pan”
rpush nonfriends “Batman”
rpush nonfriends “Betty Boop”

lrange nonfriends 0 -1
1. Peter Pan
2. Batman
3. Betty Boop
REDIS
rpoplpush nonfriends friends

lrange friends 0 -1
1. John Doe
2. Foo
3. Bar
4. Betty Boop

lrange nonfriends 0 -1
1. Peter Pan
2. Batman
REDIS
Pub/Sub.... a freaking AWESOME messaging queue
REDIS

Pro’s:
- Highly performant
- Highly scalable
- Interfaces available for many languages (Ruby: Ohm)

Cons:
- Eats your server’s memory
- Manually sharding
MONGODB
• http://mongodb.org

• Document      store

• Writes   to disk

• Hight   scalability

• Easy   sharding
MONGODB

• Organizes    data using
 collections

• Stores documents in BSON
 format, a binary-encoded
 serialization of JSON
MONGODB

use users
u = { name: “ivan”, company: “Sysdivision”, age: “32” }
users.insert(u)

users.find();
- { "_id" : ObjectId("4d5ea4e79faeda067681e214"),
"name" : "ivan", company: “Sysdivision”, "age" : "32" }
MONGODB
use users
u = { name: “ivan”, company: “Sysdivision”, age: “32” }
users.insert(u)

db.users.find({name: “ivan”});
- { "_id" : ObjectId("4d5ea4e79faeda067681e214"),
"name" : "ivan", company: “Sysdivision”, "age" : "32" }

db.users.find();
db.users.find().skip(20).limit(10);
MONGOID
class User
  include Mongoid::Document
  field :name
  field :birthday, :type => date
  field :money, :type => float, :default => 0.0
  embedded_in :company
end
class Company
  field :name
  embeds_one :user
end
MONGOID
company = Company.create(:name => ‘Sysdivision’)

company.create_user(
                        :name => ‘John Doe’,
                        :birthday => ’12/7/1982’,
                        : money => 0
                       )

User.find(:name => ‘John Doe’)
User.where(:name => /.*ohn.*/)
MONGOID
User.any_of(
              { :name => ‘John Doe’ },
              { :money.gt 10 }
             )

User.any_in(:name => [‘John’, ‘Foo’, ‘Bar’])

User.where(:name => ‘John Doe’).and(:money.gt 10)

Post.all_in(:tags => [‘ruby’, ‘code’, ‘mongo’])
MONGODB

Pro’s:
- Highly performant
- Highly scalable
- Easy sharding
- Ultra powerful querying
- Interfaces available for many languages (Ruby:
mongo_mapper, mongoid)
NOSQL AWESOMENESS
QUESTIONS?




        Ivan Belmonte
        http://ibelmonte.com
        ivan@ivanhq.net

More Related Content

KEY
MongoDB at RuPy
PDF
Drupal: Casos de Usos Internacionais
PDF
Introduction to mongoDB
PPTX
Evergreen Documentation Lightning Talk
PDF
Realtime video streaming the open source way
PPTX
2011_12_4K research in PSNC
PDF
RTSP Protocol Analysis Of A Streaming Thorugh IPv6 Network
PDF
RTSP Streaming Server - Demo Streaming RTSP Protocol Over IPv6 Network
MongoDB at RuPy
Drupal: Casos de Usos Internacionais
Introduction to mongoDB
Evergreen Documentation Lightning Talk
Realtime video streaming the open source way
2011_12_4K research in PSNC
RTSP Protocol Analysis Of A Streaming Thorugh IPv6 Network
RTSP Streaming Server - Demo Streaming RTSP Protocol Over IPv6 Network

Viewers also liked (17)

DOC
Remote monitoring system
PDF
FFMPEG TOOLS
PDF
Internationalization(i18n) of Web Page
PDF
Video Streaming
PDF
Remote Management of Embedded Android Devices
PPT
FFMPEG on android
PDF
Streaming Media Server Setup Manual
PPT
Lecture Slides for Location based Services [Android]
PPT
PPTX
Operational Agriculture Monitoring System Using Remote Sensing
PDF
Location-Based Services on Android
DOCX
Location Tracking of Android Device Based on SMS.
PPTX
Internet of things for Smart Home
PDF
Smart Home technologies
PPTX
Smart homes
PPTX
Bus tracking application in Android
PDF
Android College Application Project Report
Remote monitoring system
FFMPEG TOOLS
Internationalization(i18n) of Web Page
Video Streaming
Remote Management of Embedded Android Devices
FFMPEG on android
Streaming Media Server Setup Manual
Lecture Slides for Location based Services [Android]
Operational Agriculture Monitoring System Using Remote Sensing
Location-Based Services on Android
Location Tracking of Android Device Based on SMS.
Internet of things for Smart Home
Smart Home technologies
Smart homes
Bus tracking application in Android
Android College Application Project Report
Ad

Similar to Nosql redis-mongo (20)

KEY
KeyValue Stores
PDF
Mongodb my
PDF
MongoDB
PDF
Scaling the Web: Databases & NoSQL
KEY
MongoDB SF Ruby
KEY
MongoDB EuroPython 2009
PPTX
Drop acid
PDF
Chris Lea - What does NoSQL Mean for You
KEY
MongoDB SF Python
PPTX
MongoDB
PDF
Using Spring with NoSQL databases (SpringOne China 2012)
PDF
MongoDB at FrozenRails
PDF
Mongo db transcript
KEY
MongoDB London PHP
PDF
Open source Technology
PPTX
Mongo db
PPTX
Einführung in MongoDB
PDF
WebCamp: Developer Day: The Big, the Small and the Redis - Андрей Савченко
PPTX
mongodb_DS.pptx
KeyValue Stores
Mongodb my
MongoDB
Scaling the Web: Databases & NoSQL
MongoDB SF Ruby
MongoDB EuroPython 2009
Drop acid
Chris Lea - What does NoSQL Mean for You
MongoDB SF Python
MongoDB
Using Spring with NoSQL databases (SpringOne China 2012)
MongoDB at FrozenRails
Mongo db transcript
MongoDB London PHP
Open source Technology
Mongo db
Einführung in MongoDB
WebCamp: Developer Day: The Big, the Small and the Redis - Андрей Савченко
mongodb_DS.pptx
Ad

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
A Presentation on Artificial Intelligence
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
MYSQL Presentation for SQL database connectivity
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Digital-Transformation-Roadmap-for-Companies.pptx
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation_ Review paper, used for researhc scholars
Understanding_Digital_Forensics_Presentation.pptx
A Presentation on Artificial Intelligence
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
CIFDAQ's Market Insight: SEC Turns Pro Crypto
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Nosql redis-mongo

  • 2. SQL: THE BEGINNING • Data structured on tables using columns • Data on one column is the key for making relationships with other tables • Normalization • RDBMS
  • 4. RDBMS BENEFITS • Normalization (a common standard format for accessing data) • Data consistency • Persistence • Consistency • Replication
  • 6. RDBMS PROBLEMS • Highcost on performing complex operations over a big database • High system load: scalability needs • Difficult failover recovery • Difficult denormalization
  • 7. NOSQL TO THE RESCUE!
  • 8. NOSQL IS... •A storage system for format free data • Web scale • Software darwinism • Different types of solutions depending on the needs: Key-value, Documents, Graphs, Objects...
  • 9. REDIS • http://redis.io Redis is SEXY • Key-value store • In memory • Persistent (periodical asynchronous writes to disk) • All operations are atomic
  • 10. REDIS Types of data Cool operations • Hashes • RPOPLPUSH • Sets (arrays) • Pub/Sub • Lists
  • 11. REDIS HSET myuser “email” “ivan@ivanhq.net” HSET myuser “web” “http://ibelmonte.com” HSET myuser “blog” “http://ivanh.net” HGET myuser “email” - ivan@ivanhq.net
  • 12. REDIS sadd myuser:books “jackass” sadd myuser:books “jackass2” sadd myuser:books “Dude, where’s my car?” sadd myuser:books “The hangover” smembers myuser:books 1. jackass 2. jackass2 3. Dude, where’s my car? 4. The hangover
  • 13. REDIS rpush friends “John Doe” rpush friends “Foo” rpush friends “Bar” lrange friends 0 -1 1. John Doe 2. Foo 3. Bar
  • 14. REDIS rpush nonfriends “Peter Pan” rpush nonfriends “Batman” rpush nonfriends “Betty Boop” lrange nonfriends 0 -1 1. Peter Pan 2. Batman 3. Betty Boop
  • 15. REDIS rpoplpush nonfriends friends lrange friends 0 -1 1. John Doe 2. Foo 3. Bar 4. Betty Boop lrange nonfriends 0 -1 1. Peter Pan 2. Batman
  • 16. REDIS Pub/Sub.... a freaking AWESOME messaging queue
  • 17. REDIS Pro’s: - Highly performant - Highly scalable - Interfaces available for many languages (Ruby: Ohm) Cons: - Eats your server’s memory - Manually sharding
  • 18. MONGODB • http://mongodb.org • Document store • Writes to disk • Hight scalability • Easy sharding
  • 19. MONGODB • Organizes data using collections • Stores documents in BSON format, a binary-encoded serialization of JSON
  • 20. MONGODB use users u = { name: “ivan”, company: “Sysdivision”, age: “32” } users.insert(u) users.find(); - { "_id" : ObjectId("4d5ea4e79faeda067681e214"), "name" : "ivan", company: “Sysdivision”, "age" : "32" }
  • 21. MONGODB use users u = { name: “ivan”, company: “Sysdivision”, age: “32” } users.insert(u) db.users.find({name: “ivan”}); - { "_id" : ObjectId("4d5ea4e79faeda067681e214"), "name" : "ivan", company: “Sysdivision”, "age" : "32" } db.users.find(); db.users.find().skip(20).limit(10);
  • 22. MONGOID class User include Mongoid::Document field :name field :birthday, :type => date field :money, :type => float, :default => 0.0 embedded_in :company end class Company field :name embeds_one :user end
  • 23. MONGOID company = Company.create(:name => ‘Sysdivision’) company.create_user( :name => ‘John Doe’, :birthday => ’12/7/1982’, : money => 0 ) User.find(:name => ‘John Doe’) User.where(:name => /.*ohn.*/)
  • 24. MONGOID User.any_of( { :name => ‘John Doe’ }, { :money.gt 10 } ) User.any_in(:name => [‘John’, ‘Foo’, ‘Bar’]) User.where(:name => ‘John Doe’).and(:money.gt 10) Post.all_in(:tags => [‘ruby’, ‘code’, ‘mongo’])
  • 25. MONGODB Pro’s: - Highly performant - Highly scalable - Easy sharding - Ultra powerful querying - Interfaces available for many languages (Ruby: mongo_mapper, mongoid)
  • 27. QUESTIONS? Ivan Belmonte http://ibelmonte.com ivan@ivanhq.net

Editor's Notes