NoSQLデータモデリング技法#TechLunch

E60aa4f80303f3f386898546ddb3686a?s=47 Livesense Inc.
April 21, 2014
30

 NoSQLデータモデリング技法#TechLunch

NoSQLデータモデリング技法
2014/01/29 (水) 12:00-13:00 @ Livesense TechLunch
発表者:佐藤 洋輔

E60aa4f80303f3f386898546ddb3686a?s=128

Livesense Inc.

April 21, 2014
Tweet

Transcript

  1. Tech Lunch 2014/01/29 Yosuke  Sato

  2. None
  3. NoSQLσʔλϞσϦϯάٕ๏ •  ϒϩάهࣄ •  ݪจ͕2012/03/01 •  http://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling- techniques/ •  ຋༁൛͕ϗοςϯτϦͩͬͨؾ͕͢Δ

    •  https://gist.github.com//matope/2396234
  4. ΞδΣϯμ •  NoSQLͷਐԽ •  NoSQLσʔλϞσϦϯάͷجຊݪଇ •  ۩ମతͳϞσϦϯάٕज़ •  ࣍ݩ࡟ݮ • 

    ෳ߹ΩʔΠϯσοΫε •  ϚςϦΞϥΠζυύε •  ωετ͞Εͨू߹ •  etc…
  5. NoSQLͷਐԽ

  6. None
  7. SQL͔ΒNoSQL΁ •  SQLͱϦϨʔγϣφϧϞσϧ͸ɺϢʔβʔͱͷΠϯλϥΫγϣϯΛ૝ఆͯ͠ ࡞ΒΕ͍ͯΔ •  ूܭ͞ΕͨϨϙʔτ৘ใ •  τϥϯβΫγϣϯɺεΩʔϚɺࢀর׬શੑΛॏࢹ •  σδϚͱ͔యܕతͳΤϯυϢʔβʔ

    •  ιϑτ΢ΣΞΞϓϦέʔγϣϯ͸Ͳ͏͔ͩͬͨʁ •  ฒྻੑɺ׬શੑɺҰ؏ੑɺόϦσʔγϣϯΛॏࢹ •  ͋·ΓਓؒͷϢʔβʔ͕໌ࣔతʹ੍ޚ͕ͨ͠Δੑ࣭Ͱ͸ͳ͍ •  ্هSQLͷ௕ॴΛ੾Γࣺͯͯɺͦͷଞͷੑ࣭ʹ໨Λ޲͚ͨ͜ͱ͕ɺ৽ͨͳਐԽͷ࢝·Γ
  8. NoSQLͷϞσϧ͝ͱͷྑ͠ѱ͠ Key-Value ετΞ Ordered-Key- Value ετΞ BigTable σʔλϕʔε υΩϡϝϯτ σʔλϕʔε

    (શจݕࡧ Τϯδϯ) άϥϑ σʔλϕʔε ࠨྡ͔Βͷ վྑ఺ - Ωʔൣғͷॲ ཧ DBαΠυͰͷ ஋ͷϞσϦϯ ά (CFɺCɺTS) ೚ҙͷෳࡶ͞ ͷ εΩʔϚ σʔλϕʔε αΠυͷΠϯ σοΫε άϥϑߏ଄ ܽ఺ Ωʔൣғͷॲ ཧʹऑ͍ ૉ๿͗͢Δ Ϟσϧ ૉ๿͗͢Δ Ϟσϧ ୅ද࣮૷ Oracle Coherence Redis Kyoto Cabinet Hbase Cassandra MongoDB CouchDB Lucene Solr Neo4j FlockDB
  9. NoSQLσʔλϞσϦϯάͷجຊݪଇ •  ΞΫηεύλʔϯ͔Βͷઃܭ •  ϦϨʔγϣφϧϞσϦϯά •  ࣗ෼͸Ͳͷ౴͑Λ͍࣋ͬͯΔ͔ʁ͔Βઃܭ •  ៉ྷʹਖ਼نԽ͔ͯ͠Βνϡʔχϯά • 

    NoSQLσʔλϞσϦϯά •  ࣗ෼͸ԿΛ஌Γ͍ͨͷ͔ʁ͔Βઃܭ •  ஌Γ͍ͨ৘ใͷੑ࣭ʹΑͬͯ͸࠷ॳ͔Βσʔλෳ੡ɺඇਖ਼نԽ
  10. ۩ମతͳϞσϦϯάٕज़

  11. ྻڍՄೳͳΩʔ(Enumerable Keys) •  KeyValueετΞ࠷େͷར఺ •  γϯϓϧͳϋογϡΩʔʹΑΔߴ͍ωοτϫʔΫ෼அ଱ੑ •  εέʔϥϏϦςΟ •  ͦͷ୅ΘΓʹయܕతͳൣғݕࡧΛ͢Δ͜ͱ͕Ͱ͖ͳ͍(BETWEENతͳ)

    •  ΞτϛοΫͳΧ΢ϯλʔʹΑͬͯγʔέϯγϟϧͳIDΛੜ੒ •  AUTO_INCREMENTతͳ •  ͱ͋ΔID͔ΒɺͦͷલޙͷIDΛࢉग़ͯ͠τϥόʔε •  Ωʔ: userID_messageID •  ࠷ॳʹ༩͑ΒΕͨmessageID͔Βͷ૿ݮ •  Ωʔ: userID_date_messageID •  ೔ຖͷάϧʔϐϯά
  12. ࣍ݩ࡟ݮ(Dimensionality Reduction) •  ଟ࣍ݩσʔλΛKey-ValueͷΑ͏ͳγϯϓϧͳϞσϧʹϚοϐϯά •  ఻౷తͳ஍ܗ৘ใγεςϜ •  Quadtree •  R-Tree

    •  σʔλϘϦϡʔϜ͕ڊେͳ࣌͸ૢ࡞͕ߴͭ͘͘ •  Geohash •  Ң౓ܦ౓৘ใΛόΠφϦΤϯίʔυ •  ॱং෇͖ͷσʔλϕʔε(Ordered-KVSɺBigTable)ͱ૬ੑ͕ྑ͍ •  ۙ๣ݕࡧ
  13. None
  14. ͏ΜɺΑ͘Θ͔Βͳ͍

  15. ΠϯσοΫεςʔϒϧ(Index Table) •  ਌੾ʹ΋RDB͕σϑΥϧτͰ༻ҙͯ͘͠Ε͍ͯΔΠϯσοΫε •  NoSQLʹ͸ͦΕ͕ͳ͍͕࣌··͋ΔͷͰɺࣗલͰ༻ҙ •  Usersςʔϒϧ͕CityଐੑΛ͍࣋ͬͯΔͱ͖ɺCitiesςʔϒϧ͕UserIDsଐੑΛ΋ͭ •  ͍ΘΏΔٯҾ͖

    •  ύϑΥʔϚϯεϖφϧςΟ •  Ұ؏ੑΛอ࣋͢Δ࢓૊Έ͕ඞཁ •  ϚςϦΞϥΠζυϏϡʔͷ૬ࣅܗ
  16. ෳ߹ΩʔΠϯσοΫε(Composite Key Index) •  ॱং෇͖Ωʔ •  ΩʔͷલํҰகʹΑΔൣғεΩϟϯ •  ෳ߹ΩʔʹΑΔूܭ • 

    (ނ)cospa(HBase)Ͱ΋ ঎඼ͷεςʔλεͰ ঎඼ΛߜΓࠐΉ࣌ʹར༻͍ͯͨ͠ •  Ձ֨ΛՃ޻ͯ͠ΩʔʹೖΕͯΈͨΓ
  17. ϚςϦΞϥΠζυύε(Materialized Paths) •  ໦ߏ଄ͷ࠶ؼతͳτϥόʔεΛආ͚ΔͨΊͷςΫχοΫ •  ͦΕͧΕͷϊʔυʹɺͦͷશͯͷ਌͔ࢠڙͷࣝผࢠΛଐੑ͚ͮΔ •  τϥόʔαϧແ͠Ͱશͯͷ૆ઌ͔ࢠଙΛٻΊΔ͜ͱ͕ग़དྷΔ •  IDͷηοτ͔IDΛ݁߹ͨ͠୯Ұͷจࣈྻ

    •  ਖ਼نදݱΛ༻͍ͯύεͷҰ෦ʹҰக͢ΔϊʔυΛݕࡧ •  ϚςϦΞϥΠζυύεͱݴͬͨΒɺcospaͰ΋kagunoͰ΋͓ੈ࿩ʹͳ͍ͬͯΔ͜ Ε •  https://github.com/stefankroes/ancestry
  18. None
  19. None
  20. ωετ͞Εͨηοτ(Nested Sets) •  πϦʔঢ়ͷߏ଄ମΛϞσϦϯά͢ΔͨΊͷඪ४తͳςΫχοΫ •  RDB͸΋ͪΖΜɺKey-ValueετΞɺυΩϡϝϯτσʔλϕʔεͳΜͰ΋͟͝Ε •  লϝϞϦ •  τϥόʔαϧͳ͠Ͱ༩͑ΒΕͨϊʔυͷશͯͷ༿ΛϑΣονग़དྷΔ

    •  ༿ͷ௥Ճ͸ΠϯσοΫεͷߴՁͳߋ৽Λى͜͢ͷͰɺૠೖͱߋ৽͸௒ߴίετ •  ͜Ε΋ศརͳgem͕… •  https://github.com/collectiveidea/awesome_nested_set
  21. None
  22. ଞʹ΋͍Ζ͍ΖͳϞσϦϯάٕज़ͳࡌ͍ͬͯ ΔͷͰ https://gist.github.com//matope/2396234

  23. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠m(_ _)m