Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Datomic Spotlight
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Amitay Horwitz
August 24, 2017
Programming
110
0
Share
Datomic Spotlight
Amitay Horwitz
August 24, 2017
More Decks by Amitay Horwitz
See All by Amitay Horwitz
Transducers
amitayh
0
59
Building event sourced systems with Kafka Streams
amitayh
1
1.2k
Event Sourcing with Kafka Streams
amitayh
1
1.2k
TDD For The Curious
amitayh
0
290
Other Decks in Programming
See All in Programming
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
220
自動レビューエンジンの実装と運用 ~レビューのない世界へ~
kurukuru1999
2
300
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.3k
Swiftのレキシカルスコープ管理
kntkymt
0
210
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
200
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.1k
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
1k
誰も頼んでない機能を出荷した話
zekutax
0
150
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
230
net-httpのHTTP/2対応について
naruse
0
390
CSC307 Lecture 17
javiergs
PRO
0
300
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
110
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
830
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
350
Skip the Path - Find Your Career Trail
mkilby
1
130
WCS-LA-2024
lcolladotor
0
610
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.8k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
180
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
220
New Earth Scene 8
popppiees
3
2.3k
So, you think you're a good person
axbom
PRO
2
2k
Transcript
DATOMIC @amitayh THE FUNCTIONAL DATABASE
FULL DISCLOSURE ⚠
ABOUT DATOMIC • Developed by Cognitect • Initial release 2012
• Designed by Rich Hickey (author of the Clojure programming language) • Used by Facebook, Netflix, more…
FACTS ✅
FACTS • “Abraham Lincoln is the president of the United
States”
FACTS • “Abraham Lincoln is the president of the United
States” • “Abraham Lincoln was elected president of the United States on March 4, 1861”
FACTS • Abraham Lincoln • Position • President • March
4, 1861 Entity Attribute Value Timestamp
FACT = DATOM Entity Attribute Value Tx Operation
FACT = DATOM Entity Attribute Value Tx Operation 1033 :first-name
"Abraham" 260 add 1033 :last-name "Lincoln" 260 add 1033 :position "Lawyer" 277 add
FACT = DATOM Entity Attribute Value Tx Operation 1033 :first-name
"Abraham" 260 add 1033 :last-name "Lincoln" 260 add 1033 :position "Lawyer" 277 add 1033 :position "President" 522 add
FACT = DATOM Entity Attribute Value Tx Operation 1033 :first-name
"Abraham" 260 add 1033 :last-name "Lincoln" 260 add 1033 :position "Lawyer" 277 add 1033 :position "President" 522 add 1033 :position "President" 881 retract
FACT BASED MODEL Facts Facts Facts Facts Facts Facts Facts
Facts Time Facts Facts Time
GIT Facts Facts Facts Facts Objects Facts Facts Objects Time
Facts Objects Time
A DATABASE • A collection of datoms • At a
specific point in time • An immutable value
DATABASE AS A VALUE • Same as 42 is a
value • Safe to share, easy to reason about • Functions that take a database as an argument, or return a database
TIME BUILT IN • Get the database value as of,
or since, a point in time • See how the database would have looked like as if certain transactions took place • Reactive transaction reports
QUERIES
DATALOG • Equivalent to relational model + recursion • Declarative,
expressive and powerful • Pattern matching style • No more string concatenation!
EXAMPLE DATABASE Entity Attribute Value 42 :email
[email protected]
43 :email
[email protected]
42 :orders 107 42 :orders 141
DATA PATTERN Constrains the results returned, binds variables: [?customer :email
?email] Attribute Value Entity
DATA PATTERN Constrains the results returned, binds variables: [?customer :email
?email] Constant Variable Variable
Entity Attribute Value 42 :email
[email protected]
43 :email
[email protected]
42
:orders 107 42 :orders 141 “Find all customers with emails” [?customer :email ?email]
Entity Attribute Value 42 :email
[email protected]
43 :email
[email protected]
42
:orders 107 42 :orders 141 “Find a particular customer’s email” [42 :email ?email]
Entity Attribute Value 42 :email
[email protected]
43 :email
[email protected]
42
:orders 107 42 :orders 141 “What attributes does 42 have?” [42 ?attribute]
Entity Attribute Value 42 :email
[email protected]
43 :email
[email protected]
42
:orders 107 42 :orders 141 “What attributes and values does 42 have?” [42 ?attribute ?value]
WHERE CLAUSE [:find ?customer :where [?customer :email]] Data pattern
FIND CLAUSE [:find ?customer :where [?customer :email]]
IMPLICIT JOIN [:find ?customer :where [?customer :email] [?customer :orders]] “Find
all the customers who have placed orders”
PREDICATES [:find ?item :where [?item :item/price ?price] [(< 50 ?price)]]
“Find the expensive items”
CALLING FUNCTIONS [:find ?customer ?product :where [?customer :ship-address ?addr] [?adde
:zip ?zip] [?product :product/weight ?weight] [?product :product/price ?price] [(Shipping/estimate ?zip ?weight) ?ship-cost] [(<= ?price ?ship-cost)]] “Find me the customer/product combinations where the shipping cost dominates the product cost”
ARCHITECTURE
DATABASE ROLES • Queries • Transactions • Consistency • Storage
BREAK DOWN
DATOMIC COMPONENTS Peer library Transactor Storage
PEER LIBRARY Transactor Storage Peer library Your app • Embedded
in your app • Executed queries locally
Peer library Your app cache PEER LIBRARY Transactor Storage •
Reads data from storage • Caches locally
Peer library Your app cache Peer library Your app cache
Peer library Your app cache SCALE HORIZONTALLY Transactor Storage
TRANSACTOR Transactor Storage Peer library Your app • Standalone service
• Scales vertically
Transactor TRANSACTOR Transactor Storage Peer library Your app • Standalone
service • Scales vertically • Hot standby for failover
Transactor TRANSACTOR Storage Peer library Your app • Coordinates writes
• Guarantees ACID transactions (isolation level “serializable”)
Storage Transactor TRANSACTOR Peer library Your app • Writes transaction
log to storage • Generates indices
Peer library Your app cache Peer library Your app cache
Peer library Your app cache Storage Transactor TRANSACTOR • Broadcasts live updates
STORAGE Transactor Storage Peer library Your app • Provided as
a service • Many different backends
LOCAL STORAGE Transactor Storage Peer library Your app • Memory
• Filesystem • Great for testing!
NEARBY STORAGE Transactor Storage Peer library Your app • SQL
database (any JDBC)
DISTRIBUTED STORAGE ☁ Transactor Storage Peer library Your app •
DynamoDB • Riak • CouchBase • Cassandra • …
Peer library Your app cache Peer library Your app cache
Peer library Your app cache SHARED MEMCACHED Transactor Storage Memcached
EVENT SOURCING? • Datomic is lower level - facts vs
events • Annotate transactions! • Querying already built in • Listen on transaction queue to build reactive systems
Q&A
RESOURCES • http://www.datomic.com/ • Intro to Datomic by Rich Hickey
- http://wix.to/b8CQABU • The Value of Values by Rich Hickey - http://wix.to/D8CRABU • Datomic Datalog - http://wix.to/cMCQABU