Introduction to Graph Databases
andd Neo4j
N 4j
WHAT IS A GRAPH DATABASE?
1
Module What is a Graph?
Overview What is a Graph Database?
Why a Graph Database?
Graph Databases vs Relational Databases
Graph Databases vs Document Databases
Examples of Graph Databases
Node
Relation
Node
2
Easily extendable and expandable
Graphs Friendly to the human brain
Whiteboard compatible
3
A graphh database
d t b i a
is
database that uses graph
structures to represent and
store data
All about relationships
Performance
Graph Flexibility
Databases
Agility
Q
Query l
language
4
Property Graph Model
Relationships are
Nodes and
Contains nodes named and
relationships
contain directed with a
and relationships
properties start and end
node
Joanna Microsoft
Name: Joanna Works_For Name: Microsoft
City: Salt Lake City Since: 2010/1/1 City: Salt Lake City
Married: true Rocks: true
Why a Graph Database?
“Use a relational database for all
applications”
“Consider the type of database for
every application you’re writing”
5
Why a Graph Database?
Structure and
Highly related
Flexible schema queries are
data
brain friendly
Graph Databases vs. Relational Databases
Relational Graph
Tables Nodes
Schema with nullables No schema
Relations with foreign keys Relation is first class citizen
Related data fetched with joins Related data fetched with a pattern
6
Relational Databases Advantages
Highly Calculations
Grouping of data
structured data within one table
The Foreign Key System
Customer
CustomerId Name City
1 J
Joanna S ltL k Cit
SaltLakeCity
Order LineItem
OrderId CustomerId Date OrderId ProductId Quantity
1 1 2015/1/1 1 1 5
Product
ProductId Description Use
1 Candle Inside
7
Social network
Friends of friends structure
mySQL and Neo4j
Partner and 1,000,000 people
Vukotic's Each with an average of 50 friends
Experiment Depth 2: Find all friends of a user's friends
Depth 3: Find all friends of friends of a
user's friends
Etcetera
Results
Depth Rel.Db(s) Neo4j(s) #records
2 0,016 0,01 ~2500
3 30,267 0,168 ~110000
4 1543,505 1,359 ~600000
5 Unfinished 2,132 ~8000000
8
Relational Database Normalization
Created when disk space was
Normalization is encouraged
expensive
A Social Graph
Cyber ITActive
John Cathy Deborah Jennifer Mike
Graphs ALM Testing Java .NET Web API
9
A graph is a collection of nodes
connected by relationships
Summary p databases are flexible and
Graph
performant with highly related data
All database types have their place
Relational databases great for tables
Graph
p databases g great in manyy scenarios
with related data
10