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
Graph databases for fun and profit (Geekcamp.sg)
Search
vivekprahlad
August 18, 2012
Technology
490
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Graph databases for fun and profit (Geekcamp.sg)
vivekprahlad
August 18, 2012
More Decks by vivekprahlad
See All by vivekprahlad
Continuous Delivery in Practice
vivekprahlad
0
58
Other Decks in Technology
See All in Technology
マイナンバーカード本人確認の実装比較(OAuth/OIDC Numa (Immersion) Workshop 2026) / 20260825 numa-12
oidfj
PRO
0
260
わたしが知り合いゼロの勉強会に 行けるようになるまで
r5ni4
2
790
平文パスワードはログに“残り” ── 肝心の侵入は“痕跡すら残らない”
kuroneko13
0
130
暗号化?某ファイルストレージはどうなるの!? 3rd Partyとうまく付き合う秘密度ラベル設計
kasada
0
200
巨大気象データと戦う ― サロゲートモデル学習を高速化する圧縮技術
gpuunite_official
0
270
internal/testlog で遊ぼう
rokuosan
0
220
Oracle MCP Servers Explained
thatjeffsmith
1
500
AWSとGitHub Actionsの責任境界と 組織で安全に使用する取り組み
nealle
0
150
サービス内で複数のOP・ASを連鎖させる(OAuth/OIDC Numa (Immersion) Workshop 2026)
oidfj
PRO
0
260
:syncing_time:
sksat
2
750
カーネルまで探検して理解するふたつの自動計装
sumiyae
0
310
VLMで2.3万枚のPyCon JP写真を検索!
terapyon
1
500
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
480
Making Projects Easy
brettharned
120
6.7k
Scaling GitHub
holman
464
140k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
900
Crafting Experiences
bethany
1
260
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
480
Raft: Consensus for Rubyists
vanstee
141
7.6k
How to Ace a Technical Interview
jacobian
281
24k
Transcript
Graph databases for fun and profit Vivek Prahlad
About me
None
None
Contributor to Neo4j.rb
Multitenancy, Versioning, Performance
Author of Frankenstein
A graph primer What can you use graph databases for?
Examples (Neo4j.rb)
A graph primer What can you use graph databases for?
Examples (Neo4j.rb)
What is a graph?
A graph is an abstract representation of a set of
objects where some pairs of objects are connected by links
Graphs are all around us
Object graphs
Product Order Customer places 1: n chooses 1: n
None
None
http://tambrahmrage.tumblr.com/post/8594230361/rage-against-the-macchinar
None
None
None
None
None
None
Undirected Graph
Directed Graph
Knows Knows
Knows Knows Name: Vivek Name: Paul Name: Andy
Knows Knows Name: Vivek Name: Paul Name: Andy Since: April
2012
Knows Knows Name: Vivek Name: Paul Name: Andy Since: April
2012 Since: September 2003
What on earth is a graph database?
A database with an explicit graph structure
Each node knows it’s neighbours
Typically directed graphs
None
Two main operations
Find nodes
Either explicitly
Node[node_id]
Or use an index
Car.find(“name: Ferr*”)
Traverse, given an origin
None
Graph algorithms
Shortest path
14 2 11 15 14 9 6 9 10
Graph database options
None
None
The examples will use Neo4j
What is Neo4j?
Neo4j is an ACID compliant graph database
“Graph databases like Neo4j are an esoteric but powerful member
of the NoSQL family”
Capacity?
32 Billion nodes 32 Billion relationships 64 Billion properties
Threadsafe
Single depth transactions
Nested transactions: ‘Placebo’ transactions
Lucene integration
TWO query languages
Cypher
Gremlin
Advanced and enterprise editions for monitoring, replication, hot backup
A graph primer What can you use graph databases for?
Neo4j.rb
Typical applications
None
None
None
Recommendation systems
None
Fraud detection
Geospatial analysis
None
But
Most complex domains
Involve an object graph
A graph primer What can you use graph databases for?
Examples (Neo4j.rb)
Modeling graphs is important
None
Partitioning data crucial
Neo4j Language bindings
Java, C#, Ruby, Node.js
Embedded vs. REST server
Runs on JRuby
Builds on ActiveModel
validations, nested attributes, composed_of, all work
Built in migration support
Multitenancy support
Versioning
3 layer API
Layer 1: Nodes, Relationships
Neo4j::Transaction run do Neo4j::Node.new(:name => “A”) end
Layer 2: Node and Relationship Mixins
class SportsCar include Neo4j::NodeMixin property :brand end
Layer 3: Rails Model support
class SportsCar < Neo4j::Rails::Model property :brand end
class SportsCar < Neo4j::Rails::Model include Neo4j::Rails::Versioning property :brand end
class SportsCar < Neo4j::Rails::Model include Neo4j::Rails::Versioning property :brand, :index =>:fulltext
end
class User < Neo4j::Rails::Model attr_accessor :password attr_accessible :email, :password, :password_confirmation,
:pending_account after_save :encrypt_password email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i # add an exact lucene index on the email property property :email, :index => :exact has_one(:avatar).to(Avatar) validates :email, :presence => true,:format => { :with => email_regex } validates :email, :uniqueness => true, :unless => :pending_account? accepts_nested_attributes_for :avatar, :allow_destroy => true end
Versioning
None
None
None
None
None
Multitenancy
None
None
A few cypher examples
START a=node(3) MATCH (a)-[:KNOWS]->(b)-[:KNOWS]->(c) RETURN a,b,c
|a | b | c | |Node[3]{name->Vivek}|Node[2] |Node[3]|
START d=node(1), e=node(2) MATCH p = shortestPath( d-[*..15]->e ) RETURN
p
(1)--[KNOWS,2]-->(3)--[KNOWS,0]-->(4)--[KNOWS,3]-->(2)
In conclusion
Graphs are a compelling way to store interconnected data
No O/R mismatch
More widely applicable than you’d think
Try it out!
https://github.com/andreasronge/ neo4j.git
Thank You
@vivekprahlad
[email protected]