Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Datomicについて

 Datomicについて

Takahiro Hozumi

March 27, 2013
Tweet

Other Decks in Programming

Transcript

  1. όοΫΤϯυ͕ࣗ༝ • In-Memory • Local Storage (H2) • Amazon DynamoDB

    ※ • PostgreSQL ※ • Riak ※ • Infinispan ※ ※ Pro Edition
  2. Comment id body book 1 “good” 3 2 “bad” 2

    3 “not bad” 2 Book id isbn title 1 123456 “abc” 2 789101 “foo” 3 987654 “hello” RDB User id name age 1 “taro” 14 2 “john” 36 3 “mike” 25
  3. υΩϡϝϯτܕ(Mongodb) User { "_id" : ObjectId("509f41b38626d09726e978ed"), "name" : "taro", "tel"

    : "123-4567-8901", "address": { "zip": 123-4567, "city": "tokyo" } }
  4. Comment { "_id" : ObjectId("509f41b38626d09726e978ed"), "name" : "taro", "tel" :

    "123-4567-8901", "address": { "zip": 123-4567, "city": "tokyo" } } Book { "_id" : ObjectId("509f41b38626d09726e978ed"), "name" : "taro", "tel" : "123-4567-8901", "address": { "zip": 123-4567, "city": "tokyo" } } υΩϡϝϯτܕ(Mongodb) User { "_id" : ObjectId("509f41b38626d09726e978ed"), "name" : "taro", "tel" : "123-4567-8901", "address": { "zip": 123-4567, "city": "tokyo" } }
  5. Datomic ࣮ମ Entity ଐੑ Attribute ஋ Value ࣌ؒ Time •

    ࣄ࣮ͷ࠷খ୯Ґ Datom • ྫ) ଠ࿠ͷॅॴ͸ਆಸ઒ݝɻڈ೥͸ɻ
  6. Datom Entity Attribute Value Time 7 :name “taro” T123 7

    :address “ਆಸ઒” T124 2 :name “foo” T125
  7. Datom • ςʔϒϧ͸ͳ͍ Entity Attribute Value Time 7 :name “taro”

    T123 7 :address “ਆಸ઒” T124 2 :name “foo” T125
  8. Datom • ςʔϒϧ͸ͳ͍ • ଐੑ໊͕িಥ͢ΔΜ͡Όʁ Entity Attribute Value Time 7

    :name “taro” T123 7 :address “ਆಸ઒” T124 2 :name “foo” T125
  9. Datom • ໊લۭؒͰিಥ͠ͳ͍ Entity Attribute Value Time 7 :user/name “taro”

    T123 7 :user/address “ਆಸ઒” T124 2 :book/name “foo” T125
  10. API ͸จࣈྻͰ͸ͳ͘σʔλ (d/transact connection [[:db/add 7 :user/address “ਆಸ઒”] [:db/add 7

    :user/name “taro”] [:db/retract 8 :book/name “foo”]]) DatomͷϕΫλ
  11. Schemaఆٛྫ {:db/id #db/id[:db.part/db] :db/ident :user/address :db/valueType :db.type/string :db/cardinality :db.cardinality/one :db/unique

    :db.unique/value :db/index true :db/doc "A user's address"} ଐੑ໊ ܕ Ұ͔ଟ͔ ϢχʔΫ ಛੑ
  12. Schemaఆٛྫ {:db/id #db/id[:db.part/db] :db/ident :user/address :db/valueType :db.type/string :db/cardinality :db.cardinality/one :db/unique

    :db.unique/value :db/index true :db/doc "A user's address"} ଐੑ໊ ܕ Ұ͔ଟ͔ ϢχʔΫ ಛੑ ΠϯσοΫε
  13. Schemaఆٛྫ {:db/id #db/id[:db.part/db] :db/ident :user/address :db/valueType :db.type/string :db/cardinality :db.cardinality/one :db/unique

    :db.unique/value :db/index true :db/doc "A user's address"} ଐੑ໊ ܕ Ұ͔ଟ͔ ϢχʔΫ ಛੑ ΠϯσοΫε આ໌
  14. ΫΤϦʔ [:find ?e :in $ :where [$ ?e :user/address “ਆಸ઒”]]

    SQLͷSELECTΈ͍ͨͳɻฦͯ͠ཉ͍͠෺ ֎͔Β༩͑Δೖྗ
  15. ΫΤϦʔ [:find ?e :in $ :where [$ ?e :user/address “ਆಸ઒”]]

    SQLͷSELECTΈ͍ͨͳɻฦͯ͠ཉ͍͠෺ ֎͔Β༩͑Δೖྗ SQLͷwhereΈ͍ͨͳɻߜΓࠐΈ
  16. ΫΤϦʔ [:find ?e :in $ :where [$ ?e :user/address “ਆಸ઒”]]

    SQLͷSELECTΈ͍ͨͳɻฦͯ͠ཉ͍͠෺ ֎͔Β༩͑Δೖྗ SQLͷwhereΈ͍ͨͳɻߜΓࠐΈ ม਺ɻ ಉ໊͡લͳΒࣗಈతʹରԠɻ $͸σʔλϕʔεΛද͢
  17. ΫΤϦʔ [:find ?e :in $ :where [$ ?e :user/address “ਆಸ઒”]]

    SQLͷSELECTΈ͍ͨͳɻฦͯ͠ཉ͍͠෺ ֎͔Β༩͑Δೖྗ SQLͷwhereΈ͍ͨͳɻߜΓࠐΈ ม਺ɻ ಉ໊͡લͳΒࣗಈతʹରԠɻ $͸σʔλϕʔεΛද͢ ఆ਺ɻݻఆ͞Εͨ஋
  18. ఆ਺ͰߜΓࠐΈ [:find ?e :in $ :where [?e :user/address “ਆಸ઒”] [?e

    :user/name “taro”]] ਆಸ઒͔ͭtaroͰߜΓࠐΈ
  19. ೖྗ஋ͰߜΓࠐΈ [:find ?e :in $ ?addr ?name :where [?e :user/address

    ?addr] [?e :user/name ?name]] ೖྗ஋͕όΠϯυ͞ΕΔ
  20. ͜Ε͸ߜΓࠐΈ͡Όͳ͍ [:find ?e ?name :in $ :where [?e :user/address “ਆಸ઒”]

    [?e :user/name ?name]] ਆಸ઒ͷਓશһͷ໊લ΋ฦ͢
  21. ઃܭ఩ֶ(2) • The Value of Values (஋ͷՁ஋) Rich Hickey keynote

    • ʮ஋(σʔλ)͸࠷ߴͩʂ͋Ε΋͜Ε΋͍ ͍͜ͱͣ͘ΊɻPLOPɺ܅͸ͩΊͩʯ
  22. ઃܭ఩ֶ(2) • The Value of Values (஋ͷՁ஋) Rich Hickey keynote

    • ʮ஋(σʔλ)͸࠷ߴͩʂ͋Ε΋͜Ε΋͍ ͍͜ͱͣ͘ΊɻPLOPɺ܅͸ͩΊͩʯ ͱͯ΋໘ന͍Α
  23. ऴΘΓ Photo credit cover(universe) write_adam "IC443, the Jellyfish nebula" CC

    BY-NC 2.0 http://www.flickr.com/photos/astroporn/5234588981/ fact(lens)Raymond Larose "No Crop, No Edit" CC BY-NC-ND 2.0 http://www.flickr.com/photos/lenscrack/5165225746/ PLOP(musical chairs) rich "I guess this was for musical chairs?" CC BY 2.0 http://www.flickr.com/photos/spine/1009892593/ PLOP(paint) ALL CHROME "SUPER SUNDAY" CC BY-NC-SA 2.0 http://www.flickr.com/photos/allchrome/5423888378/ information disappear(footprint) Jeff Kubina "Footprints" CC BY-ND 2.0 http://www.flickr.com/photos/kubina/21208990/ over there(monkey) Adn! "Worst than jail" CC BY-NC-ND 2.0 http://www.flickr.com/photos/hojas_cayendo/5549137958/ PLOP(musical chairs) niiicedave "IMGP0670cr - Kampout Fresno 2011 - Saturday - Kamptown Races - musical chairs" CC BY-SA 2.0 http:// www.flickr.com/photos/33671002@N00/6144480939/ PLOP(musical chairs) Takahiro Hozumi "musical_chairs" CC BY-SA 2.0 http://www.flickr.com/photos/87914538@N06/8594162617 limited resource era(cat) lincolndisplayimages.com "Arran cat (2)" CC BY-NC 2.0 http://www.flickr.com/photos/robdray/1118614948/ fact(water) Chaval Brasil "Drop in a Dime" CC BY-NC-ND 2.0 http://www.flickr.com/photos/chavals/2869153410/ liberty from place(jump) blinkingidiot "Jump for Joy" CC BY-ND 2.0 http://www.flickr.com/photos/45325473@N04/4910647166/ append only db(library) Thomas Hawk "And I Saw Your Hand With a Loose Grip on a Very Tight Ship" CC BY-NC 2.0 http://www.flickr.com/photos/ thomashawk/85441961/ decompose jobs(lego) Jez Page"257/365 - LEGO" CC BY-NC-SA 2.0 http://www.flickr.com/photos/jezpage/4990873353/ storage service(cast) Paco CT "It is Friday, let's have a drink, or two" CC BY-NC-SA 2.0 http://www.flickr.com/photos/paco_calvino/3513790048/ peer(book) Marwa Morgan "Oldies are Goldies :D" CC BY-NC-ND 2.0 http://www.flickr.com/photos/marwamorgan/2602038800/ transactor(sewing-machine-needle) Theen ... "Stitching Machine" CC BY-NC-SA 2.0 http://www.flickr.com/photos/theenmoy/8407089950/ review(book-cat)raider of gin "cat reading" CC BY 2.0 http://www.flickr.com/photos/fairerdingo/2320356661/ backend variety(colorful-sewing-machine) Hellsgeriatric "Singer Sewing Machine" CC BY-NC-ND 2.0 http://www.flickr.com/photos/hellsgeriatric/ 2037304681/ efficient query(fish) SteveD. "Big Eye Scad, Kona Hawaii" CC BY 2.0 http://www.flickr.com/photos/42507736@N02/6022657611/ time travel(clock) Roby Ferrari "SAF#2" CC BY-SA 2.0 http://www.flickr.com/photos/roberto_ferrari/281640001/ efficient write(car) Design By Zouny "Geneva Car Show 2010" CC BY 2.0 http://www.flickr.com/photos/zouny/5054816002/ schema(book-shelf) Swamibu "Iqra: Read" CC BY-NC 2.0 http://www.flickr.com/photos/swamibu/2868288357/ the design philophy(inner-clock) GuySie "Photo365 #5 - Pretty on the inside" CC BY-SA 2.0 http://www.flickr.com/photos/guysie/5327472911/ the design philophy(blue-pattern) Alex Abian "Alien Technology" CC BY-NC-ND 2.0 http://www.flickr.com/photos/xtyler/3629765611/