In this talk the general idea of graph databases is presented and the execution of a graph traversal is shown.
The talk has been given at NoSQL UG Cologne (in Nov. 2013)
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
GraphDatabases and what we can use them for
1. Graphs, Databases and what we can use them for
Michael Hackstein
@mchacki
November 6, 2013
c 2013 triAGENS GmbH | 2013-11-6
2. About me
Still Student (Master Informatik) at RWTH
Just handed in my thesis
Software developer at triAGENS GmbH, CGN
Part of the ArangoDB team
c 2013 triAGENS GmbH | 2013-11-6
3. Table of contents
1 Definition
2 Use Cases
3 Databases
4 Traversals
5 Visualisation
c 2013 triAGENS GmbH | 2013-11-6
4. What is a graph?
A set of arbitrary objects, called vertices
c 2013 triAGENS GmbH | 2013-11-6
5. What is a graph?
A set of arbitrary objects, called vertices
And a set of relations between them, called edges
c 2013 triAGENS GmbH | 2013-11-6
6. Formal Definition
Let V be the set of vertices
Let E ⊆ V × V be the set of edges
Define G = (V , E ) is a graph
c 2013 triAGENS GmbH | 2013-11-6
7. Formal Definition
Let V be the set of vertices
Let E ⊆ V × V be the set of edges
Define G = (V , E ) is a graph
Define δ + (n) =
v ∈V |(n,v )∈E
1 is the indegree of n ∈ V
Define δ − (n) =
1 is the outdegree of n ∈ V
Define δ(n) =
as the degree of n ∈ V
v ∈V |(v ,n)∈E
δ + (n) + δ − (n)
c 2013 triAGENS GmbH | 2013-11-6
8. Directed Graphs
Edges have a direction
One vertex is the source
The other vertex is the target
Formal: (a, b) ∈ E
(b, a) ∈ E
And (a, b) ∈ E ∧ (b, a) ∈ E ⇒ (a, b) = (b, a)
c
d
b
a
c 2013 triAGENS GmbH | 2013-11-6
10. Undirected Graphs
Edges do not have a direction
No vertex is source or target
Formal: (a, b) ∈ E ⇔ (b, a) ∈ E
And (a, b) ∈ E ∧ (b, a) ∈ E ⇒ (a, b) = (b, a)
c
d
b
a
c 2013 triAGENS GmbH | 2013-11-6
14. Where else to store Graphs?
c 2013 triAGENS GmbH | 2013-11-6
15. How to store Graphs?
We will have an example using ArangoDB.
First Example: Create new database using Graphs API
DEMO TIME
c 2013 triAGENS GmbH | 2013-11-6
16. How to store Graphs?
Second Example: You already have vertices.
How to add edges?
DEMO TIME
c 2013 triAGENS GmbH | 2013-11-6
17. But what can we do with the data now?
c 2013 triAGENS GmbH | 2013-11-6
18. Queries on graphs
Mechanism to query a graph
Starts at one specific vertex
Searches all connected vertices
Searches children of these vertices
Until predefined boundary is reached
Order of vertices can be configured
c 2013 triAGENS GmbH | 2013-11-6
19. The visitor
Active at each searched vertex
Can execute queries on this vertex like collecting attributes
Does know the path followed to reach the current vertex
Does not know vertices that will be visited in future
c 2013 triAGENS GmbH | 2013-11-6