Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Charlotte.rb - "Comics" Is Hard

2,214 views

Published on

Domain modeling/alternative database presentation given at Charlotte.rb

Charlotte.rb - "Comics" Is Hard

  1. 1. “Comics” Is Hard: On Domains and Databases Ben Sco eld – Viget Labs
  2. 2. domains
  3. 3. biology
  4. 4. Kingdom Animalia Phylum Chordata Class Mammalia Order Carnivora Family Felidae Genus Panthera Species tigris ickr: pandiyan
  5. 5. Animalia Chordata Mammalia Carnivora Felidae Panthera tigris ickr: pandiyan
  6. 6. kingdoms phyla classes orders families genera species
  7. 7. Problem The levels are imaginary
  8. 8. kingdoms subphyla phyla superclasses subclasses classes superorders suborders orders superfamilies subfamilies families subgenera genera subspecies species varieties
  9. 9. kingdoms subphyla phyla superclasses subclasses ? classes superorders suborders orders superfamilies subfamilies families subgenera genera subspecies species varieties
  10. 10. taxa subspecies species varieties
  11. 11. Species ickr: cpurrin1
  12. 12. Reproductive Isolation ickr: superciliousness
  13. 13. Reproductive Isolation ickr: superciliousness
  14. 14. ickr: chiotsrun
  15. 15. ickr: niznoz
  16. 16. Numerical taxonomy
  17. 17. Cladistics
  18. 18. clades organisms
  19. 19. Problem Cladistics is historical and counter-intuitive
  20. 20. ickr: goellnitz
  21. 21. ickr: goellnitz pcoin
  22. 22. The Challenge Unclear, imprecise domain
  23. 23. comics
  24. 24. publishers titles issues
  25. 25. publishers imprints titles issues
  26. 26. publishers imprints titles volumes issues
  27. 27. publishers imprints titles volumes trades issues reprints
  28. 28. publishers imprints titles volumes trades issues reprints variants
  29. 29. publishers imprints titles names volumes trades issues reprints variants
  30. 30. publishers imprints ? titles names volumes trades issues reprints nested set? variants
  31. 31. publishers imprints ?!?! titles names volumes trades issues reprints nested set? variants
  32. 32. science fiction noir horror genres? independent Martial Arts historical superhero Pirate
  33. 33. publishers imprints #&*! titles names volumes trades genres issues reprints nested set? variants
  34. 34. The Challenge Complete insanity
  35. 35. nosql altdb postrelational lesssql
  36. 36. http://thisisindexed.com/2009/02/just-because-you-can-doesnt-mean-you-should/
  37. 37. key-value stores
  38. 38. dynomite tokyo cabinet project voldemort pstore redis
  39. 39. require "rubygems" require "tokyocabinet" include TokyoCabinet bdb = BDB::new # B-Tree database; keys may have multiple values bdb.open("casket.bdb", BDB::OWRITER | BDB::OCREAT) # store records in the database, allowing duplicates bdb.putdup("key1", "value1") bdb.putdup("key1", "value2") bdb.put("key2", "value3") bdb.put("key3", "value4") # retrieve all values p bdb.getlist("key1") # => ["value1", "value2"] # range query, find all matching keys p bdb.range("key1", true, "key3", true) # => ["key1", "key2", "key3"] http://www.igvita.com/2009/02/13/tokyo-cabinet-beyond-key-value-store/
  40. 40. Biology x Comics x
  41. 41. Configuration ✓ Caching ✓ Translations ✓
  42. 42. document databases
  43. 43. couchdb jackrabbit mongodb rddb riak
  44. 44. { 'name':'Ben Scofield', 'twitter':'@bscofield' } { 'name':'Jim Van Fleet', 'adjective':'awesomesauce' }
  45. 45. class Question include MongoMapper::Document key :number, Integer, :required => true key :text, String, :required => true many :choices end class Choice include MongoMapper::EmbeddedDocument key :text, String, :required => true end
  46. 46. Biology ✓ Comics x
  47. 47. { ‘kingdom’:‘Animalia’, ‘phylum’:‘Chordata’, ‘subphylum’:‘Vertebrata’, ‘class’:‘Mammalia’, ‘subclass’:‘Eutheria’, ‘order’:‘Carnivora’, ‘family’:‘Felidae’, ‘subfamily’:‘Panthernae’, ‘genus’:‘Pantera’, ‘species’:‘tigris’, ‘name’:‘Wanda’ }
  48. 48. { ‘kingdom’:‘Animalia’, ‘subkingdom’:‘Eumetazoa’, ‘phylum’:‘Chordata’, ‘subphylum’:‘Vertebrata’, ‘class’:‘Mammalia’, ‘subclass’:‘Theria’, ‘order’:‘Carnivora’, ‘suborder’: ‘Caniformia’, ‘family’:‘Canidae’, ‘subfamily’:‘Caninae’, ‘tribe’:‘Canini’, ‘genus’:‘Canis’, ‘species’:‘lupus’, ‘subspecies’:‘familiaris’, ‘name’:‘Daisy’ }
  49. 49. graph databases
  50. 50. allegograph hypergraphdb neo4j activeRDF
  51. 51. http://neotechnology.com/why-neo
  52. 52. http://markorodriguez.com/Lectures_ les/risk-symposium2009.pdf
  53. 53. ickr: 9948354@N08
  54. 54. Biology ✓ Comics ✓
  55. 55. Animalia ... Felidae subfamilyof genusof Panthernae genusof Panthera speciesof tigris member 001 age name weight 3 Wanda 300
  56. 56. Animalia ... Felidae subfamilyof genusof Panthernae genusof Panthera species speciesof type tigris 010 name tigris member 001 age name weight 3 Wanda 300
  57. 57. Group IV orderof Picornavirales familyof Picornaviridae genusof Rhinovirus speciesof human rhinovirus A member 002
  58. 58. class Mammalia Group IV group orderof orderof Carnivora Picornavirales familyof familyof Felidae Picornaviridae subfamilyof Panthernae genusof genusof genusof Panthera Rhinovirus speciesof speciesof human tigris rhinovirus A member member 001 002
  59. 59. DC imprintof titleof DC Universe Green titleof 001 Lantern nameof genreof volumeof genreof Volume 1 Sci Fi Superhero genreof issueof genreof 002 precedes Issue #2 number coverof #1 003
  60. 60. require 'neo4j' Neo4j::Transaction.run do dc = Neo4j::Node.new dc[:name] = 'DC' dc_universe = Neo4j::Node.new dc_universe[:name] = 'DC Universe' dc.relationships.outgoing(:imprints) << dc_universe rel = dc.relationships.outgoing(:imprints).first rel[:started] = 1980 vol1 = Neo4j::Node.new vol1[:started] = 1941 vol1[:ended] = 1949 vol1[:name] = 'Green Lantern' dc.relationships.outgoing(:titles) << vol1 dc_universe.relationships.outgoing(:titles) << vol1 # ... end
  61. 61. other alternatives
  62. 62. column-oriented constant in-memory streaming temporal
  63. 63. selection
  64. 64. None Key-Value Many-One Document-Oriented Many-Many Relational Many-Many ++ Graph
  65. 65. polyglot persistence
  66. 66. { ‘title’:‘I Love Cheese’ ‘content’:‘Cheese is...’ ‘posted’:’24 Sept 2009’ ‘comments’:[{ ‘author’:‘Joe Schmoe’ ‘posted’:’24 Sept 2009’ ‘content’:‘First!’ }, {...}] }
  67. 67. Tag Tag Post General Life 1ec8264 Work Food 1ec8264 Fitness Writing bae294a Life Food Writing { ‘title’:‘I Love Cheese’ Family ‘content’:‘Cheese is...’ ‘posted’:’24 Sept 2009’ ‘comments’:[{ ‘author’:‘Joe Schmoe’ ‘posted’:’24 Sept 2009’ ‘content’:‘First!’ }, {...}] }
  68. 68. HTTP application application
  69. 69. HTTP application
  70. 70. application
  71. 71. application
  72. 72. Thank You ben sco eld - @bsco eld http://bensco eld.com http://www.viget.com/extend http://www.speakerrate.com/bsco eld

×