NoSQL                             Scott Gonyea                              Epoch, LLC.                                   ...
NoSQLTuesday, December 14, 2010           2
{ {{ {{{ NoSQL }}} }} }                              * GONG *Tuesday, December 14, 2010                      3
NoSQL                             So... What is it?Tuesday, December 14, 2010                       4
NoSQL                   •         It’s “Not SQL”                   •         Less Structured; Sometimes Un-Structured     ...
NoSQL                             Recap and ComparisonTuesday, December 14, 2010                          6
NoSQL               SELECT persons.*                 FROM      persons                 LEFT JOIN automobiles              ...
NoSQL               SELECT persons.*                 FROM      persons                 LEFT JOIN automobiles              ...
Persons                                                       NoSQL                                  Colors               ...
NoSQL                                                 Key-Value Stores                                                AKA:...
NoSQL                                 Key-Value Stores                   • Very Fast                   • Simple           ...
NoSQL                                        Document[-Oriented] Stores               Very De-Normalized                  ...
NoSQL                             Document[-Oriented] Stores                   • Analogous to Printed Documents           ...
NoSQL                                                 Graph Databases                             untitled                ...
NoSQL                                           Graph Databases                   •      Relationships Derived Through “Di...
NoSQL                             Let’s Explore: redisTuesday, December 14, 2010                          16
NoSQL                                      Let’s Explore: redis                   • Versatile Key/Value Store             ...
redis                                Needs a Better R Package                             > install.packages("rredis")    ...
redis                              doRedis (rredis + foreach)                                    redis Subscriptions      ...
redis                                      Sets, From Ruby               ruby                                    redis    ...
redis                             Set Intersections, Unions, Rand                               admins = %w{bernard frank ...
redis                                    Atomic String Operations                             redis.set "foo", "bar"      ...
redis                                        Atomic Operations                             # Strings                      ...
Nächste SlideShare
Wird geladen in …5
×

Los Angeles R users group - Dec 14 2010 - Part 3

2.273 Aufrufe

Veröffentlicht am

Veröffentlicht in: Business, Technologie
0 Kommentare
0 Gefällt mir
Statistik
Notizen
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Keine Downloads
Aufrufe
Aufrufe insgesamt
2.273
Auf SlideShare
0
Aus Einbettungen
0
Anzahl an Einbettungen
1.441
Aktionen
Geteilt
0
Downloads
20
Kommentare
0
Gefällt mir
0
Einbettungen 0
Keine Einbettungen

Keine Notizen für die Folie

Los Angeles R users group - Dec 14 2010 - Part 3

  1. 1. NoSQL Scott Gonyea Epoch, LLC. @acts_as github.com/aitrus me@sgonyea.comTuesday, December 14, 2010 1
  2. 2. NoSQLTuesday, December 14, 2010 2
  3. 3. { {{ {{{ NoSQL }}} }} } * GONG *Tuesday, December 14, 2010 3
  4. 4. NoSQL So... What is it?Tuesday, December 14, 2010 4
  5. 5. NoSQL • It’s “Not SQL” • Less Structured; Sometimes Un-Structured • Usually Implies: • Key-Value Store • Document Datastore • Graph Databases (and its Variants) • Often not much more than thatTuesday, December 14, 2010 5
  6. 6. NoSQL Recap and ComparisonTuesday, December 14, 2010 6
  7. 7. NoSQL SELECT persons.* FROM persons LEFT JOIN automobiles ON persons.id = automobiles.person_id WHERE automobiles.color IS RED /* Wait! We can NORMALIZE this some more! */ SELECT persons.* FROM persons LEFT JOIN automobiles LEFT JOIN colors ON persons.id = automobiles.person_id AND colors.id = automobiles.color_id WHERE colors.name IS RED-34 /* Wait! ... */Tuesday, December 14, 2010 7
  8. 8. NoSQL SELECT persons.* FROM persons LEFT JOIN automobiles ON persons.id = automobiles.person_id WHERE automobiles.color IS RED /* Wait! We can NORMALIZE this some more! */ SELECT persons.*, automobiles.* /* Selects */ FROM persons LEFT JOIN automobiles /* Joins */ LEFT JOIN colors ON persons.id = automobiles.person_id AND colors.id = automobiles.color_id WHERE colors.name IS RED-34 /* Conditions */ /* Wait! ... */Tuesday, December 14, 2010 8
  9. 9. Persons NoSQL Colors id First Name Last Name id name 1 Seymore Butts 212 RED-34 2 Amanda Hugginkiss 213 BLUE-32 Join Table => PersonsVehicles id vehicle_id person_id color_id 1 7384 1 212 2 7231 2 212 Automobiles id make model Year 23192 Honda Civic 2003 19763 Chevy Tahoe 1998 Relationship: “Belongs To” => Vehicles id identifier automobile_id Normalization 7231 7384 1FALP62W4WH128703 4WH1287031FALP62W 23192 19763Tuesday, December 14, 2010 9
  10. 10. NoSQL Key-Value Stores AKA: Dictionary, Hash Table, etc. KV Database Key Give me what’s at “John” “John” “Jo hn ” Value at “John” “Smith” “Smith”Tuesday, December 14, 2010 10
  11. 11. NoSQL Key-Value Stores • Very Fast • Simple • Key-Value Pairs are Self-Contained ∴Easier Replication - Twitter, Facebook, Google, etc. - Also,Your ComputerTuesday, December 14, 2010 11
  12. 12. NoSQL Document[-Oriented] Stores Very De-Normalized Less De-Normalized “John Smith” “John Smith” string first_name John string first_name John string last_name Smith string last_name Smith embedded automobiles embedded automobiles document doc_id make Honda document doc_ref vehicle id(fd18d0af6c053886d) string model Civic string color Red int year 2003 string employer Epoch, LLC. string color Red fd18d0af6c053886d string employer Epoch, LLC. string make Honda string model Civic int year 2003 embedded features document string breaks anti-lock bool air_cond TRUE geo_coord made_at 39.975542, -82.992096Tuesday, December 14, 2010 12
  13. 13. NoSQL Document[-Oriented] Stores • Analogous to Printed Documents • Varying Levels of De-normalization • Documents Still Relatively Self-Contained ∴Easier Replication, Too - Twitter, Facebook, Google, etc.Tuesday, December 14, 2010 13
  14. 14. NoSQL Graph Databases untitled 6 4 5 1 3 2 Six Degrees of Separation or: How you realized you have no friends :-(Tuesday, December 14, 2010 14
  15. 15. NoSQL Graph Databases • Relationships Derived Through “Distance” • Some Use-Cases: • Geographic • Networking • Routing / Shortest Path • Social • Molecular Modeling • Kevin Bacon Jokes • Also Quite Trendy: - Twitter, Facebook, Google [Maps, Mail, & Your Life]Tuesday, December 14, 2010 15
  16. 16. NoSQL Let’s Explore: redisTuesday, December 14, 2010 16
  17. 17. NoSQL Let’s Explore: redis • Versatile Key/Value Store • Type Aware (Optional) ‣ Nums, Strings, Lists, Sets, Hashes • Atomic Operations • Subscriptions • Transactional (When needed) • Customizable DurabilityTuesday, December 14, 2010 17
  18. 18. redis Needs a Better R Package > install.packages("rredis") > require(rredis) > redisConnect() > key <- zero > value <- hero > redisSet(key, value) [1] TRUE > redisGet(key) [1] "hero"Tuesday, December 14, 2010 18
  19. 19. redis doRedis (rredis + foreach) redis Subscriptions # Uses Redis publish/subscribe messaging to distribute workloads require(doRedis) registerDoRedis(jobs) foreach(j=1:1000,.combine=sum,.multicombine=TRUE) %dopar% 4*sum((runif(1000000)^2 + runif(1000000)^2)<1)/10000000 removeQueue(jobs)Tuesday, December 14, 2010 19
  20. 20. redis Sets, From Ruby ruby redis require "redis" redis = Redis.new users = %w{albert bernard charles} redis> smembers "users" 1. "charles" users.each {|usr| redis.sadd "users", usr 2. "bernard" } 3. "albert" redis.smembers "users" # => ["charles", "bernard", "albert"]Tuesday, December 14, 2010 20
  21. 21. redis Set Intersections, Unions, Rand admins = %w{bernard frank alice} admins.each do |adm| redis.sadd "admins", adm end redis.sinter("users", "admins") # => ["bernard"] redis.sunion "admins", "users" # => ["alice", "bernard", "albert", "frank", "charles"] redis.srandmember "users" # => "albert"Tuesday, December 14, 2010 21
  22. 22. redis Atomic String Operations redis.set "foo", "bar" # => "OK" redis.append "foo", "baz" # => 6 redis.get "foo" # => "barbaz"Tuesday, December 14, 2010 22
  23. 23. redis Atomic Operations # Strings redis.set "foo", "bar" # => "OK" redis.append "foo", "baz" # => 6 redis.get "foo" # => "barbaz" # Fixnums redis.set "one", 1 # => "OK" redis.incr "one" # => 2 redis.incrby "one", 3 # => 5 redis.get "empty" # => nil redis.incr "empty" # => 1 redis.get "empty" # => "1"Tuesday, December 14, 2010 23

×