Presentation given at the national PHP conference in Poland, in Kielce, October 2011, dealing with the introduction of graph databases in PHP, taking a practical look at OrientDB.
Recommendations
lives in
John type shows
Mr
Fun Cinema B
Bean loca
tion
lik
Rome
es
shows Cinema A location
type
Thriller Se7en
s ho
ws
location Milan
Cinema C
19
Recommendations
lives in
John type shows
Mr
Fun Cinema B
Bean loca
tion
lik
Rome
es
type
shows Cinema A location ✓
x x
Thriller Se7en
s ho
ws
location Milan
Cinema C
20
Recommendations
lives in
John type shows
Mr
Fun Cinema B
Bean
✓ loca
tion
lik
Rome
es
type
shows Cinema A location ✓
x x
Thriller Se7en
s ho
ws
location Milan
Cinema C
21
Recommendations
lives in
John type shows
Mr
Fun Cinema B
✓
Bean
✓ loca
tion
lik
Rome
es
type
shows Cinema A location ✓
x x
Thriller Se7en
s ho
ws
location Milan
Cinema C
22
Recommendations
lives in
John
xFun
type Mr
✓
Bean
shows
Cinema B
✓ loca
tion
lik
Rome
es
type
shows Cinema A location ✓
x x
Thriller Se7en
s ho
ws
location Milan
Cinema C
23
Recommendations
lives in
John
x x x
Fun
type Mr
Bean
shows
Cinema B
loca
tion
lik
Rome
es
type
shows
✓
Cinema A location ✓
x x
Thriller Se7en
s ho
ws
location Milan
Cinema C
24
Recommendations
lives in
John
x x x
Fun
type Mr
Bean
shows
Cinema B
loca
tion
lik
Rome
es
type
shows
✓
Cinema A location ✓
✓ shows
x x
Thriller Se7en
location Milan
Cinema C
25
Recommendations
lives in
John
x x x
Fun
type Mr
Bean
shows
Cinema B
loca
tion
lik
Rome
es
type
shows
✓
Cinema A location ✓
✓ shows
x x
✓
Thriller Se7en
location Milan
Cinema C
26
Recommendations
lives in
John
x x x
Fun
type Mr
Bean
shows
Cinema B
loca
tion
lik
✓
Rome
es
type
shows
✓
Cinema A location ✓
✓ shows
x x
✓
Thriller Se7en
location Milan
Cinema C
27
Given your dataset, organize some clusters
Are there some nodes which cannot belong to a cluster?
They probably have some properties different from the average
Given your dataset, organize some clusters
Are there some nodes which cannot belong to a cluster?
They probably have some properties different from the average
ACHTUNG!
TERRORISTEN!
GraphDB
A graph database is any storage
system that provides index-free
adjacency.
http://www.slideshare.net/slidarko/problemsolving-using-graph-traversals-searching-scoring-ranking-and-recommendation
Step by step example
Given a list of people, find their homepages
42
Tree-based DB WAY
David Funaro
put in the Search Engine
2
find 3
1
http://davidfunaro.com
43
Tree-based DB WAY
David Funaro
The cost to find Search Engine friend HP
put in the a single
2
grows as the friends HP tables grows
find 3
1
http://davidfunaro.com
43
Local cost
Thus, as the graph grows in size,
the cost of a local step remain the same
48
any database can implicity represent a
graph
BUT
only a graph database make the graph
structure explicit
49
Benchmark
Deph RDBMS Graph
1 100ms 30ms
• 1 Million Vertex
• 4 Million Edge
2 1000ms 500ms
• Scale Free Tolopogy
3 10000ms 3000ms
• Postgres VS Neo4J
4 100000m 50000ms
s • Both Hash and BTree
5 N/A 100000m
s
50
http://markorodriguez.com/2011/02/18/mysql-vs-neo4j-on-a-large-scale-graph-traversal/
community that is building and feeding the GraphDB ecosystem
GraphDB community
ThinkerPop
Stack
Databases
data model and their
implementation
Blueprints is a collection of interfaces, implementations,
ouplementations, and test suites for the property graph data
model. Blueprints is analogous to the JDBC, but for graph
databases.
https://github.com/tinkerpop/blueprints/wiki/
a data flow Framework using Process Graph
provide a collection of "pipes" that are
connected togheter to from processing
pipelines
a graph-based programming language.
a Turing-Complete graph-base programming language
that compiles Gremlin syntax down to Pipes
a REST-full graph shell.
Allow blueprints graph to be exposed
through a RESTful API (HTTP)
use CongowOrientQuery;
$query = new Query();
$query->from(array('users'))->where('username = ?', "admin");
echo $query->getRaw();
// SELECT FROM users WHERE username = "admin"
use CongowOrientQuery;
$query = new Query();
$query->from(array('users'))->where('username = ?', "admin");
echo $query->getRaw();
// SELECT FROM users WHERE username = "admin"
use CongowOrientQuery;
$query = new Query();
$query->from(array('users'))->where('username = ?', "admin");
echo $query->getRaw();
// SELECT FROM users WHERE username = "admin"
use CongowOrientQuery;
$query = new Query();
$query->from(array('users'))->where('username = ?', "admin");
echo $query->getRaw();
// SELECT FROM users WHERE username = "admin"
$query->select(array('name', 'username', 'email'), false)
->from(array('12:0', '12:1'), false)
->where('any() traverse ( any() like "%danger%" )')
->orWhere("1 = ?", 1)
->andWhere("links = ?", 1)
->limit(20)
->orderBy('username')
->orderBy('name', true, true)
->range("12:0", "12:1");
SELECT name, username, email
FROM [12:0, 12:1]
WHERE any() traverse ( any() like "%danger%" )
OR 1 = "1" AND links = "1"
ORDER BY name, username
LIMIT 20
RANGE 12:0 12:1