introduction to graph data management...introduction to graph data management with neo4j tobias...

151
Introduction to Graph Data Management with neo4j Tobias.Lindaaker@neo4j.com @thobe #neo4j 1

Upload: others

Post on 22-May-2020

21 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Introductionto

GraphDataManagementwithneo4j

[email protected]@thobe#neo4j

1

Page 2: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Whygraphs?

Page 3: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Theworldisagraph–everythingisconnected

• people,places,events

• companies,markets

• countries,history,politics• lifesciences,bioinformatics,clinicaldata

• art,teaching

• technology,networks,machines, applications,users

• software,code,dependencies,architecture,deployments

• criminals,fraudstersandtheirbehavior5

Page 4: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

6

Thetopologyofthedataisatleastasimportantas

thedataitself

Page 5: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Humansthinkingraphs

• Weunderstandandlearnby• howsomethingnewissimilartowhatwealreadyknow

• howitdiffers• i.e.byrelatingthings

• inagraph!

7

Page 6: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Whatarepeopleusinggraphdatabasesfor?

Page 7: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

UseCases

InternalApplicationsMasterDataManagement

Networkand ITOperations

FraudDetection

Customer-FacingApplicationsReal-TimeRecommendations

Graph-BasedSearch

IdentityandAccessManagement

Page 8: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

SocialNetwork

Page 9: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

ImpactAnalysis

Page 10: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Logistics&Routing

Page 11: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Recommendations

Page 12: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

AccessControl

Page 13: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

FraudAnalysis

Page 14: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Modellingtranslationsandcomplexaccessrules

16

EN:house

house

building

EN:building

ES:edificio DE:Gebäude

SE:byggnad

ES:casa

DE:Hause

SE:hus

Page 15: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

WhiteboardFriendliness

Easy to design and model, direct representation of the model

Page 16: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Whiteboardfriendliness

Page 17: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Tom Hanks Hugo Weaving

Cloud AtlasThe Matrix

Lana Wachowski

ACTED_IN

ACTED_IN ACTED_IN

DIRECTED

DIRECTED

Whiteboardfriendliness

Page 18: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

name: Tom Hanks born: 1956

title: Cloud Atlas released: 2012

title: The Matrix released: 1999

name: Lana Wachowski born: 1965

ACTED_IN roles: Zachry

ACTED_IN roles: Bill Smoke

DIRECTED

DIRECTED

ACTED_IN roles: Agent Smith

name: Hugo Weaving born: 1960

Person

MovieMovie

Person Director

ActorPerson Actor

Whiteboardfriendliness

Page 19: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Whiteboardfriendliness

Page 20: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Introtothepropertygraphmodel

Page 21: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Neo4jFundamentals

• Nodes

• Relationships

• Properties

• Labels

Page 22: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Car

PropertyGraphModelComponents

Nodes• Representtheobjectsinthegraph• Canbelabeled

Person Person

Page 23: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Car

DRIVES

PropertyGraphModelComponents

Nodes• Representtheobjectsinthegraph• Canbelabeled

Relationships• Relatenodesbytypeanddirection

LOVES

LOVES

LIVESWITH

OWNS

Person Person

Page 24: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Car

DRIVES

name:“Dan”born:May29,1970twitter:“@dan”

name:“Ann”born:Dec5,1975

since: Jan10,2011

brand:“Volvo”model:“V70”

PropertyGraphModelComponents

Nodes• Representtheobjectsinthegraph• Canbelabeled

Relationships• Relatenodesbytypeanddirection

Properties• Name-valuepairsthatcangoonnodesandrelationships.

LOVES

LOVES

LIVESWITH

OWNS

Person Person

Page 25: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Summaryofthegraphbuildingblocks

• Nodes-Entitiesandcomplexvaluetypes

• Relationships-Connectentitiesandstructuredomain

• Properties-Entityattributes,relationshipqualities,metadata

• Labels-Groupnodesbyrole

Page 26: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

GraphQuerying

Page 27: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

WhynotSQL?

• SQLisinefficientinexpressinggraphpatternqueriesInparticularforqueriesthat• arerecursive• canacceptpathsofmultipledifferentlengths

• Graphpatternsaremoreintuitiveanddeclarativethanjoins

• SQLcannothandlepathvalues

29

Page 28: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

30

Apatternmatchingquerylanguagemadeforgraphs

• Declarative

• Expressive

• PatternMatching

Cypher

Page 29: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

PatterninourGraphModel

LOVES

Dan Ann

NODE NODERelationship

Page 30: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Cypher:ExpressGraphPatterns

(:Personname:"Dan")-[:LOVES]->(:Personname:"Ann")

LOVES

Dan Ann

LABEL PROPERTY

NODE NODE

LABEL PROPERTY

Relationship

Page 31: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Cypher:CREATEGraphPatterns

CREATE(:Personname:"Dan")-[:LOVES]->(:Personname:"Ann")

LOVES

Dan Ann

LABEL PROPERTY

NODE NODE

LABEL PROPERTY

Relationship

Page 32: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Cypher:MATCHGraphPatterns

MATCH(:Personname:"Dan")-[:LOVES]->(whom)RETURNwhom

LOVES

Dan ?

VARIABLE

NODE NODE

LABEL PROPERTY

Relationship

Page 33: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Agraphqueryexample

Page 34: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Asocialrecommendation

Page 35: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

MATCH(person:Person)-[:IS_FRIEND_OF]->(friend),(friend)-[:LIKES]->(restaurant),(restaurant)-[:LOCATED_IN]->(loc:Location),(restaurant)-[:SERVES]->(type:Cuisine)WHEREperson.name='Philip'ANDloc.location='NewYork'ANDtype.cuisine='Sushi'RETURNrestaurant.name

Asocialrecommendation

Page 36: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheSyntax

Page 37: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Nodes

Nodesaredrawnwithparentheses.

()

Page 38: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Relationships

Relationshipsaredrawnasarrows,withadditionaldetailinbrackets.

-->-[:DIRECTED]->

Page 39: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Patterns

Patternsaredrawnbyconnectingnodesandrelationshipswithhyphens,optionallyspecifyingadirectionwith>and<signs. ()-[]-()()-[]->()()<-[]-()

Page 40: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

ThecomponentsofaCypherquery

MATCH(m:Movie)RETURNmMATCHandRETURNareCypherkeywords misavariable:Movieisanodelabel

Page 41: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

ThecomponentsofaCypherquery

MATCH(p:Person)-[r:ACTED_IN]->(m:Movie)RETURNp,r,mMATCHandRETURNareCypherkeywords p,r,andmarevariables :Movieisanodelabel :ACTED_INisarelationshiptype

Page 42: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

ThecomponentsofaCypherquery

MATCHpath=(:Person)-[:ACTED_IN]->(:Movie)RETURNpathMATCHandRETURNareCypherkeywords pathisavariable:Movieisanodelabel :ACTED_INisarelationshiptype

Page 43: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

MATCH(m:Movie)RETURNm

GraphversusTabularresults

Page 44: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

MATCH(m:Movie)RETURNm.title,m.releasedPropertiesareaccessedwithvariable.property_key

GraphversusTabularresults

Page 45: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Casesensitive Nodelabels

Relationshiptypes

Propertykeys

Caseinsensitive Cypherkeywords

Casesensitivity

Page 46: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Casesensitive :Person

:ACTED_IN

name

Caseinsensitive MaTcH

return

Casesensitivity

Page 47: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Writequeries

Page 48: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheCREATEClause

CREATE(m:Movietitle:'MysticRiver',released:2003)

RETURNm

Page 49: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheSETClause

MATCH(m:Movietitle:'MysticRiver')

SETm.tagline='Weburyoursinshere,Dave.Wewashthemclean.'

RETURNm

Page 50: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheCREATEClause

MATCH(m:Movietitle:'MysticRiver')

MATCH(p:Personname:'KevinBacon')

CREATE(p)-[r:ACTED_INroles:['Sean']]->(m)

RETURNp,r,m

Page 51: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheMERGEClause

MERGE(p:Personname:'TomHanks')

RETURNp

Page 52: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheMERGEClause

MERGE(p:Personname:'TomHanks',oscar:true)

RETURNp

Page 53: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheMERGEClause

MERGE(p:Personname:'TomHanks',oscar:true)

RETURNpThereisnota:Personnodewithname:'TomHanks'andoscar:trueinthegraph,butthereisa:Personnodewithname:'TomHanks'. Whatdoyouthinkwillhappenhere?

Page 54: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheMERGEClause

MERGE(p:Personname:'TomHanks')

SETp.oscar=true

RETURNp

Page 55: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheMERGEClause

MERGE(p:Personname:'TomHanks')-[:ACTED_IN]

->(m:Movietitle:'TheTerminal')

RETURNp,m

Page 56: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

TheMERGEClause

MERGE(p:Personname:'TomHanks')-[:ACTED_IN]

->(m:Movietitle:'TheTerminal')

RETURNp,m

Thereisnota:Movienodewithtitle:"TheTerminal"inthegraph,butthereisa:Personnodewithname:"TomHanks". Whatdoyouthinkwillhappenhere?

Page 57: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

MERGE(p:Personname:'TomHanks')

MERGE(m:Movietitle:'TheTerminal')

MERGE(p)-[r:ACTED_IN]->(m)

RETURNp,r,m

TheMERGEClause

Page 58: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

MERGE(p:Personname:'YourName')

ONCREATESETp.created=timestamp(),p.updated=0

ONMATCHSETp.updated=p.updated+1

RETURNp.created,p.updated;

ONCREATEandONMATCH

Page 59: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Indexes

Wecreateindexesto:

• allowfastlookupofnodeswhichmatchlabel-propertypairs.CREATEINDEXON:Label(property)

Page 60: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Whatarethesefastlookups?

Thefollowingpredicatesuseindexes:

• Equality• STARTSWITH

• CONTAINS

• ENDSWITH

• Rangesearches

• (Non-)existencechecks

Page 61: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Howareindexesusedinneo4j?

Indexesareonlyusedtofindthestartingpointsforqueries.

Useindexscanstolookuprowsintablesandjointhemwithrowsfromothertables

Useindexestofindthestartingpointsforaquery.

Relational Graph

Page 62: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

GraphModeling

Page 63: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Models

Page 64: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Themodelingworkflow

1.Derivethequestion

2.Obtainthedata

3.Developamodel

4.Ingestthedata

5.Query/Proveourmodel

Page 65: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Developingthemodelandthequery

1.Identifyapplication/end-usergoals2.Figureoutwhatquestionstoaskofthedomain3.Identifyentitiesineachquestion4.Identifyrelationshipsbetweenentitiesineachquestion5.Convertentitiesandrelationshipstopaths

- Thesebecomethebasisofthedatamodel6.Expressquestionsasgraphpatterns

- Thesebecomethebasisforqueries

67

Page 66: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

1.Application/End-UserGoals

68

As an employeeI want to know who in the company has similar skills to meSo that we can exchange knowledge

Page 67: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

2.QuestionstoaskoftheDomain

69

As an employeeI want to know who in the company has similar skills to meSo that we can exchange knowledge

Whichpeople,whoworkforthesamecompanyasme,havesimilarskillstome?

Page 68: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

3.IdentifyEntities

Which people, who work for the same company as me, have similar skills to me?

• Person• Company• Skill

70

Page 69: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

4.IdentifyRelationshipsBetweenEntities

Which people, who work for the same company as me, have similar skills to me?

• PersonWORKSFORCompany• PersonHASSKILLSkill

71

Page 70: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

5.ConverttoCypherPaths

•Person WORKS FOR Company

•Person HAS SKILL Skill

72

Page 71: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

5.ConverttoCypherPaths

•Person WORKS FOR Company

•Person HAS SKILL Skill

72

Relationship

NodeNode Relationship

Node Node

Page 72: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

5.ConverttoCypherPaths

•Person WORKS FOR Company

•Person HAS SKILL Skill

• (:Person)-[:WORKS_FOR]->(:Company),• (:Person)-[:HAS_SKILL]->(:Skill)

72

Relationship

NodeNode Relationship

Node Node

Page 73: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

5.ConverttoCypherPaths

•Person WORKS FOR Company

•Person HAS SKILL Skill

• (:Person)-[:WORKS_FOR]->(:Company),• (:Person)-[:HAS_SKILL]->(:Skill)

72

Relationship

NodeNode Relationship

Node Node

Label Label

Label Label

Relationship Type

Relationship Type

Page 74: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

ConsolidatePattern

(:Person)-[:WORKS_FOR]->(:Company),(:Person)-[:HAS_SKILL]->(:Skill)

(:Company)<-[:WORKS_FOR]-(:Person)-[:HAS_SKILL]->(:Skill)

73

Person SkillCompany

WORKS_FOR HAS_SKILL

Page 75: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

CandidateDataModel(:Company)<-[:WORKS_FOR]-(:Person)-[:HAS_SKILL]->(:Skill)

74

name:Neo4j

name:Ian

name:ACME

Person

Company

WO

RKS_

FOR

HAS_

SKILL

name:Jacob

Person

name:Tobias

Person

WORKS_F

OR WORKS_FOR

name:Scala

name:Python

name:C#

SkillSkillSkillSkillHA

S_SK

ILL

HAS_SKILLHAS_SKILL

HAS_SKILL

HAS_SKILLHAS_

SKILL

Page 76: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

6.ExpressQuestionasGraphPattern

Which people, who work for the same company as me, have similar skills to me?

75

skill

company

Company

colleagueme

PersonWORK

S_FOR

WORKS_FOR

Skill

HAS_SKILL HAS_SKILL

Person

Page 77: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

CypherQuery

Which people, who work for the same company as me, have similar skills to me?

MATCH(company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill)

(company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill)WHEREme.name=$nameRETURNcolleague.nameASname,

count(skill)ASscore,collect(skill.name)ASskillsORDERBYscoreDESC

76

skill

company

Company

colleagueme

PersonWORK

S_FOR

WORKS_FOR

Skill

HAS_SKILL HAS_SKILL

Person

Page 78: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

CypherQuery

Which people, who work for the same company as me, have similar skills to me?

MATCH(company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill)

(company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill)

WHEREme.name=$nameRETURNcolleague.nameASname,

count(skill)ASscore,collect(skill.name)ASskillsORDERBYscoreDESC

77

skill

company

Company

colleagueme

PersonWORK

S_FOR

WORKS_FOR

Skill

HAS_SKILL HAS_SKILL

Person

1.Graph pattern

Page 79: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

CypherQuery

Which people, who work for the same company as me, have similar skills to me?

MATCH(company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill)

(company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill)WHEREme.name=$name

RETURNcolleague.nameASname,

count(skill)ASscore,collect(skill.name)ASskillsORDERBYscoreDESC

78

skill

company

Company

colleagueme

PersonWORK

S_FOR

WORKS_FOR

Skill

HAS_SKILL HAS_SKILL

Person

1. Graph pattern

2.Filter, using index if available

Page 80: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

CypherQuery

Which people, who work for the same company as me, have similar skills to me?

MATCH(company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill)

(company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill)WHEREme.name=$nameRETURNcolleague.nameASname,

count(skill)ASscore,

collect(skill.name)ASskills

ORDERBYscoreDESC

79

skill

company

Company

colleagueme

PersonWORK

S_FOR

WORKS_FOR

Skill

HAS_SKILL HAS_SKILL

Person

1. Graph pattern

2. Filter, using index if available

3.Create projection of result

Page 81: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

FirstMatch

80

name:Neo4j

name:Ian

name:ACME

Person

Company

WO

RKS_

FOR

HAS_

SKILL

name:Jacob

Person

name:Tobias

Person

WORKS_F

OR WORKS_FOR

name:Scala

name:Python

name:C#

SkillSkillSkillSkill

HAS_

SKILL

HAS_SKILLHAS_SKILL HAS_SKILL

HAS_SKILLHAS_

SKILL

skill

company

Company

colleagueme

Person

WORKS_

FOR WORKS_FOR

SkillHAS_SKILL

HAS_

SKILL

Person

Page 82: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

SecondMatch

81

name:Neo4j

name:Ian

name:ACME

Person

Company

WO

RKS_

FOR

HAS_

SKILL

name:Jacob

Person

name:Tobias

Person

WORKS_F

OR WORKS_FOR

name:Scala

name:Python

name:C#

SkillSkillSkillSkill

HAS_

SKILL

HAS_SKILLHAS_SKILL HAS_SKILL

HAS_SKILLHAS_

SKILL

skill

company

Company

colleagueme

Person

WORKS_

FOR WORKS_FOR

SkillHAS_SKILL

HAS_

SKILL

Person

Page 83: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

ThirdMatch

82

name:Neo4j

name:Ian

name:ACME

Person

Company

WO

RKS_

FOR

HAS_

SKILL

name:Jacob

Person

name:Tobias

Person

WORKS_F

OR WORKS_FOR

name:Scala

name:Python

name:C#

SkillSkillSkillSkill

HAS_

SKILL

HAS_SKILLHAS_SKILL HAS_SKILL

HAS_SKILLHAS_

SKILL

skill

company

Company

colleagueme

Person

WORKS_

FOR WORKS_FOR

SkillHAS_SKILL

HAS_

SKILL

Person

Page 84: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

ResultoftheQuery

+-------------------------------------+ | name | score | skills | +-------------------------------------+ | "Ian" | 2 | ["Scala","Neo4j"] | | "Jacob" | 1 | ["Neo4j"] | +-------------------------------------+ 2 rows

83

Page 85: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Modelingexercise:Moviegenres

Page 86: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Thequestion:shouldwemodelthemaspropertiesorasnodes?

Addingmoviegenres

vs

Page 87: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

MATCH(m:Movietitle:'TheMatrix')SETm.genre=['Action','Sci-Fi']RETURNm

Genresasproperties

Page 88: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

MATCH(m:Movietitle:'MysticRiver')SETm.genre=['Action','Mystery']RETURNm

Genresasproperties

Page 89: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Accessingamovie’sgenresisquickandeasy.

MATCH(m:Movietitle:"TheMatrix")RETURNm.genre;

Thegoodsideofproperties

Page 90: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

FindingmoviesthatsharegenresispainfulandwehaveadisconnectedpatternintheMATCHclause-asuresignyouhaveamodelingissue.

MATCH(m1:Movie),(m2:Movie)WHEREany(xINm1.genreWHERExINm2.genre)ANDm1<>m2RETURNm1,m2;

Thebadsideofproperties

Page 91: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

MATCH(m:Movietitle:"TheMatrix")MERGE(action:Genrename:"Action")MERGE(scifi:Genrename:"Sci-Fi")MERGE(m)-[:IN_GENRE]->(action)MERGE(m)-[:IN_GENRE]->(scifi)

Genresasnodes

Page 92: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

MATCH(m:Movietitle:"MysticRiver")MERGE(action:Genrename:"Action")MERGE(mystery:Genrename:"Mystery")MERGE(m)-[:IN_GENRE]->(action)MERGE(m)-[:IN_GENRE]->(mystery)

Genresasnodes

Page 93: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Findingmoviesthatsharegenresisanaturalgraphpattern.

MATCH(m1:Movie)-[:IN_GENRE]->(g:Genre),(m2:Movie)-[:IN_GENRE]->(g)RETURNm1,m2,g

Thegoodsideofnodes

Page 94: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Accessingthegenresofmoviesrequiresabitmoretyping.

MATCH(m:Movietitle:"TheMatrix"),(m)-[:IN_GENRE]->(g:Genre)RETURNg.name;

The(nottoo)badsideofnodes

Page 95: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

GenericvsSpecificRelationshiptypes

Page 96: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

RelationshipGranularity

Page 97: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

SymmetricRelationships

Page 98: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Symmetricrelationships

OR

Page 99: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

BidirectionalRelationships

Page 100: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Usesinglerelationshipandignoredirectioninqueries

MATCH(:Personname:'Eric')-[:MARRIED_TO]-(p2)RETURNp2

Page 101: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

openCypher

thestandardgraphquerylanguage

100

Page 102: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

BecominganindustrystandardforGraphQuerying

• CypheroriginallydesignedbyNeo4j

• Implementedandsupportedby• SAPHANA• Redis• BitnineAgensGraph• Gradoop

• Moresystemscoming• Spark

101

Page 103: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

openCypher

• Openlanguagedesignprocess

• Implementationsformultiplesystems

• Compatibilitytestsuite

• Grammarspecification

• Referenceimplementation

• DefiningthenextversionofCypher

https://github.com/openCypher/openCypher http://opencypher.org

102

6/20/2016 https://s3.amazonaws.com/artifacts.opencypher.org/railroad/Cypher.svg

https://s3.amazonaws.com/artifacts.opencypher.org/railroad/Cypher.svg 1/1

QueryOptions CREATE Index

DROP Index

CREATE UniqueConstraint

DROP UniqueConstraint

CREATE NodePropertyExistenceConstraint

DROP NodePropertyExistenceConstraint

CREATE RelationshipPropertyExistenceConstraint

DROP RelationshipPropertyExistenceConstraint

LoadCSV

Start

Match

Unwind

Merge

Create

Set

Delete

Remove

Foreach

With

Return

ALL UNION

BulkImportQuery

;

Page 104: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Formalsemantics

• NadimeFrancis,PaoloGuagliardo,LeonidLibkin

• Formallydefinesa(large)coreofCypher

103

Page 105: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Futureimprovements

Page 106: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

RegularPathQueries

• Conjunctivebi-directionalRegularPathQuerieswithData• Plusspecificationofacostfunctionforpaths,whichallowsformoreinterestingnotionsofshortestpath

PATH PATTERN coauth=()-[:WROTE]->(b)<-[:WROTE]-(), (b)<-[sale:SELLS]-() COST min(sale.price)

MATCH (a)-/~coauth* COST x/->(b)ORDER BY x LIMIT 10105

Page 107: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Furtherimprovements

• Supportforqueryingfrommultiplegraphs• Supportforreturninggraphs• Supportfordefiningviews

• IntegrationwithSQL

106

Page 108: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

RelationaltoGraph

Page 109: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Relationalissimple...untilitgetscomplicated...

RelationaltoGraph

!108

table1 table2join-table

Page 110: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Youknowrelational...nowconsiderrelationships...

RelationaltoGraph

!109

actors moviesactor_movie

Page 111: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

• Entity-TablesbecomeNodes

• ForeignKeysbecomeRelationships

• LinkTablesbecomeRelationships

• RemoveartificialPrimaryKeysandForeignKeys

NormalizedRelationalModeltoGraphModel

Page 112: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

• Cannotmodelorstoredataandrelationshipswithoutcomplexity

• Performancedegradeswithnumberandlevelsofrelationships,anddatabasesize

• QuerycomplexitygrowswithneedforJOINs

• Addingnewtypesofdataandrelationshipsrequiresschemaredesign,increasingtimetomarket

RDBMScan’thandlerelationshipswell

Page 113: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

ExpressComplexQueriesEasilywithCypher

Findallmanagersandhowmanypeopletheymanage,upto3levelsdown.

MATCH(boss)-[:MANAGES*0..3]->(mgr)WHEREboss.name="JohnDoe"AND(mgr)-[:MANAGES]->()RETURNmgr.nameASManager,size((mgr)-[:MANAGES*1..3]->())ASTotal

Cypher SQL

Page 114: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

• Modelyourdatanaturallyasagraphofdataandrelationships• Drivegraphmodelfromdomainanduse-cases

• Userelationshipinformationinreal-timetotransformyourbusiness• Addnewrelationshipsontheflytoadapttoyourchangingrequirements

UnlockingValuefromYourDataRelationships

Page 115: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

• Relationshipsarefirstclasscitizen

• Noneedforjoins,justfollowpre-materializedrelationshipsofnodes

• Query&Data-locality–navigateoutfromyourstartingpoints

• Onlyloadwhat’sneeded

• Aggregateandprojectresultsasyougo• Optimizeddiskandmemorymodelforgraphs

HighQueryPerformancewithaNativeGraphDB

Page 116: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Theperformanceadvantageofmaterialisedrelationships

• asamplesocialgraphwith~1,000persons

• average50friendsperperson

• pathExists(a,b)limitedtodepth4

• cacheswarmeduptoeliminatediskI/O

#persons querytime

Relationaldatabase 1,000 2000ms

Neo4j 1,000 2ms

Neo4j 1,000,000 2ms

Page 117: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

NativeGraphs

116

Page 118: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Neo4jpreservesrelationships

• Therelationshipsinyourmodelexistasfirst-classentitiesinthedatabase

• First-classentitiesinmemory

• First-classentitiesondisk

117

Page 119: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Index-freeadjacency

Neo4j• Index→Node[O(logN)]

• Node→Properties[O(1)]• Node→Edges(bytype)[O(1)]thisincludesdegreeinformation

• Edgesbytype→Edges[O(1)]

• Edge→Properties[O(1)]• Edge→source/targetNode[O(1)]

118

RelationalDatabases• Everythingisanindex

• (sometimesatablescan)

• typicallyO(logn)• (sometimeshash:O(1))• Stillindirectionthroughindex

Page 120: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Graphsatscale

119

Page 121: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Queriesscalewithdatasetsize

• Index-freeadjacencymeansqueryexecutiontimeneverdependsontotaldatasize

• Queryexecutiononlydependonthenumberofedgesactuallyrelatedtothenodesactuallyfound

• Expectedexecutiontimebasedonaveragedegree

120

Page 122: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Graphsscaleupeasierthanscalingout

• Neo4jtriviallyhandlesseveralbillionnodesandedgesinasinglegraph

• RAMsizethemainfactorforperformance

• BigRAMisnotexpensive• TerabyteRAMisreadilyavailable(evenonAWS)

• RAMsizegrowingfasterthandatasetsizes

121

Page 123: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Neo4jscalesoutqueries

• Replicatedcluster

• Faulttolerance

• Queryprocessingcapacityscaleout

122

Page 124: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Neo4jscalesinreality

• Realcustomers,suchasAlbumprinterhavegraphsinproduction thatarelargerthan• 1billionnodes• 2.5billionedges

• Othercustomershavehad>90%ofthesocialgraphofFacebookreplicatedinNeo4j(beforeFacebookrestrictedtheirdatausepolicies)

123

Page 125: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

LearnmoreaboutNeo4j

Page 126: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

1. DownloadNeo4j:http://neo4j.com/download/

2. Starttheserver.

3. Itshouldberunningon:http://localhost:7474

4. Log-inwithdefaultcredentialsuser:neo4j password:neo4j

5. Chooseanewpassword

We’regoodtogo!

GettingstartedwithNeo4j

Page 127: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

• :playintro-tolearntheNeo4jqueryinterface

• :playmovies-simpleexamplesonasimpledataset

• :playnorthwind-graph-theclassicnorthwindexampleasagraph• :playhttp://guides.neo4j.com/fundamentals/cypher_the_basics.html introductiontoCypher

• :playhttp://guides.neo4j.com/modeling_airportsatutorialongraphdatamodeling

• :playhttp://guides.neo4j.com/reco/fileatutorialonhowtouseNeo4jforrecommendations

TutorialsforlearningNeo4j

126

Page 128: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

DeveloperPages

neo4j.com/developer

• IntrotoGraphs

• RDBMStoGraphs

• DataImport&DataModeling

• LanguageGuides&Drivers• Visualization• Neo4jEcosystem

Page 129: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

GraphAcademy

neo4j.com/graphacademy

• Online&ClassroomTraining

• UniversityProgram

• Certification

• Webinars• GraphDays,GraphTalks

Page 130: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

neo4j.com/graphacademy/neo4j-certification/1hourcertificationexamcovers:

• Cypher

• DataModeling

• Clustering• andmore...

BecomeaNeo4jCertifiedProfessional

Page 131: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

neo4j.com/docs/cypher-refcard/current/

CypherReferenceCard

Page 132: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

neo4j.com/docs neo4j.com/docs/developer-manual/current neo4j.com/docs/operations-manual/current

DeveloperDocumentation

Page 133: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

neo4j.com/developer/kb• FrequentlyAskedQuestionsandAnswers

• CanonicalSource• MaintainedbyourSupportandFieldteam

• Tagged• Versionspecific

KnowledgeBase

Page 134: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

github.com/neo4j-examples

ExampleApplications

Page 135: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

neo4j.meetup.com

MeetupGroups

Page 136: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

neo4j.com/slack

Slack

Page 137: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

github.com/neo4j github.com/neo4j-contrib github.com/neo4j-examples

GitHub

Page 138: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

stackoverflow.com/questions/tagged/neo4j

StackOverflow

Page 139: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Books

neo4j.com/booksFree,highvaluee-booksThirdpartypublications

Page 140: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

• Haveaninterestingproject,use-case?• Wecanhelpyoupromoteitwitharticles,talks,webinars

• Wroteatool,library,connector?• We’dlovetomakeitknowninourcommunity

• Havequestionsaboutlicensing&pricing?• Reachoutwithyourquestions,wecanhelpclarify

• WanttoworkonNeo4j?• Wehavemanycooljobs,pleaseapply• Wealsohaveopenresearchtopics

• Emailme• [email protected]

Talktous

Page 141: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Researchtopics

thatweareinterestedincollaboratingon

140

Page 142: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

GraphIndexes

• Topology-basedindexes• Pathindexes• Indexingofnodesbasedonrelatednodes

• Howtoensurecomplexindexesareconsistentwhenthedatachanges

• <yourideahere>• anythingthatcanbeusedtospeedupqueries

141

Page 143: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

GraphPartitioning

• Howtosplitagraphintomultiplepartitionsinordertohandlelargergraphs

• Automaticpartitioning

• Schema-guidedpartitioning

• <yourideahere>

142

Page 144: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

DistributedQueryExecution

• Dividingtheworkofonequeryovermultipleworkers

• Bothinapartitionedenvironment• andinareplicatedenvironment

143

Page 145: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

EfficientDataStructures

• Betterwaysofrepresentinggraphsandindexes

• Onpersistentstorage

• Inmemory/cache

144

Page 146: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Semantic/Intentionallocking

• and/orotherwaysofensuringconsistentupdatesinaconcurrentsystem

• Bothwhenthedataispartitioned,• andwhenthedataisreplicated,• aswellasonasinglemachinewithmanythreads

145

Page 147: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

GraphMetricsandStatistics

• thatwecancomputeandmaintainuptodatewhilethegraphisbeingupdatedwithlowcostoverhead

• thatcaneitherbeusedtodirectlyansweruserqueries

• ortobetteroptimisequeries

146

Page 148: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Queryoptimisation

• moreefficientwaystoevaluatequeries

• betteralgorithmsforfindingan“optimal”plan

147

Page 149: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

GraphQueryLanguages

• EvolutionofCypher• Newwaysofqueryinggraphs

• Languagesandmodelsforexpressingalgorithmsongraphs

• <yourideahere>• anythingthatmakepeoplemoresuccessfulandefficientinmakingsenseofdata

148

Page 150: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

FaultTolerance

• Resilientfaulttolerantsystems

• withaslowoverheadaspossible

149

Page 151: Introduction to Graph Data Management...Introduction to Graph Data Management with neo4j Tobias .Lindaaker@neo4j.com @thobe #neo4j 1 Why graphs? The world is a graph – everything

Thankyou!Questions?

[email protected]@thobe#neo4j

150