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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
AWS環境のセキュリティ不安を解消した企業事例 ~よくある課題と対策を一挙公開~
asanoharuki
0
190
データと地図で読む 大井町の「かわるもの、かわらないもの」
yoshiyama_hana
0
380
Git 研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
1
460
Flutter研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
1
150
AIエージェントがあれば技術書なんてすぐ書けるでしょ→無理でした
watany
6
490
副作用のある Lambda でも Lambda Power Tuning は使えるのか / lambda-power-tuning-side-effects
koukihosaka
2
150
StepFunctionsとGraphRAGを活用した暗黙知活用のためのRAG基盤
yakumo
0
180
reFACToring
moznion
1
620
Multicaで30個のミニプロジェクトをAIエージェント運用して見えてきたこと
eiei114
1
670
コンポーネント名には何を含めるべきなのか? / what-should-be-included-in-component-names
airrnot1106
0
110
なぜ、あなたのAPIは使われないのか? AX時代の設計原則、ガードレール、運用体制
yokawasa
1
230
書籍セキュアAPIについて
riiimparm
0
350
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
390
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
810
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Optimizing for Happiness
mojombo
378
71k
Utilizing Notion as your number one productivity tool
mfonobong
4
460
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Skip the Path - Find Your Career Trail
mkilby
1
170
Product Roadmaps are Hard
iamctodd
55
12k
A designer walks into a library…
pauljervisheath
211
24k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
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]