This document discusses using graph databases to model relationships between data. It provides examples of using a graph database called Neo4j to model relationships between people and groups they belong to. It also discusses how a graph database can be used to model the complex relationships between wolves, other animals, and how their interactions affect river stability by following paths in the graph.
36. Hint:
Relationships Matter
Put all of us into a database.
!
Ask an RDBMS:
“What's the average age of everyone here?”
!
Ask Neo4j:
“Who should I get to know better?”
49. Nodes
uid: ABK
name: Andreas
uid: STK
where:
Stockholm
uid: SFO
where: San
Francisco
uid: BOS
where: Boston
Member
Group
Group
Group
with Labels
Relationships with Type
MEMBER_OF
MEMBER_OF
MEMBER_OF
since: 2009
since: 2013
since: 2012
Property Graph
50. Nodes
uid: ABK
name: Andreas
uid: STK
where:
Stockholm
uid: SFO
where: San
Francisco
uid: BOS
where: Boston
Member
Group
Group
Group
with Labels
Relationships with Type
MEMBER_OF
MEMBER_OF
MEMBER_OF
since: 2009
since: 2013
since: 2012
Properties on both
Property Graph
55. How Wolves Change Rivers:
Query for Trophic Cascades
!
MATCH path = (:Animal {Entity:"Wolves"})-[*]->(:Landscape {Entity:"Rivers"})
WITH extract(node IN nodes(path) | node.Yellowstone) AS factor, rand() AS number
RETURN factor AS How_Wolves_Affect_RiverStability
ORDER BY number
LIMIT 5
56. How Wolves Change Rivers:
Query for Trophic Cascades
!
MATCH path = (:Animal {Entity:"Wolves"})-[*]->(:Landscape {Entity:"Rivers"})
WITH extract(node IN nodes(path) | node.Yellowstone) AS factor, rand() AS number
RETURN factor AS How_Wolves_Affect_RiverStability
ORDER BY number
LIMIT 5