An Introduc/on to Neo4j @iansrobinson - - PowerPoint PPT Presentation

an introduc on to neo4j
SMART_READER_LITE
LIVE PREVIEW

An Introduc/on to Neo4j @iansrobinson - - PowerPoint PPT Presentation

An Introduc/on to Neo4j @iansrobinson ian.robinson@neotechnology.com #neo4j Neo4j is a Graph Database #neo4j Neo4j is a Graph Database #neo4j Neo4j is a Graph Database #neo4j


slide-1
SLIDE 1

#neo4j

An ¡Introduc/on ¡to ¡Neo4j

@iansrobinson ian.robinson@neotechnology.com

slide-2
SLIDE 2

#neo4j

Neo4j ¡is ¡a ¡Graph ¡Database

slide-3
SLIDE 3

#neo4j

Neo4j ¡is ¡a ¡Graph ¡Database

slide-4
SLIDE 4

#neo4j

Neo4j ¡is ¡a ¡Graph ¡Database

slide-5
SLIDE 5

#neo4j

Neo4j ¡is ¡a ¡Graph ¡Database

slide-6
SLIDE 6

#neo4j

Neo4j ¡is ¡a ¡Graph ¡Database

slide-7
SLIDE 7

#neo4j

Nodes ¡& ¡Proper/es

slide-8
SLIDE 8

#neo4j

Nodes ¡& ¡Proper/es

slide-9
SLIDE 9

#neo4j

Nodes ¡& ¡Proper/es

slide-10
SLIDE 10

#neo4j

Rela/onships

slide-11
SLIDE 11

#neo4j

Rela/onships

slide-12
SLIDE 12

#neo4j

Neo4j

slide-13
SLIDE 13
slide-14
SLIDE 14

32 ¡billion ¡nodes 32 ¡billion ¡rela/onships 64 ¡billion ¡proper/es

slide-15
SLIDE 15

#neo4j

slide-16
SLIDE 16

#neo4j

slide-17
SLIDE 17

#neo4j

How ¡do ¡I ¡query ¡the ¡data?

hIp://opfm.jpl.nasa.gov/ hIp://news.xinhuanet.com

slide-18
SLIDE 18

Why ¡Neo4j?

slide-19
SLIDE 19

Why ¡Neo4j?

Schema-­‑free

slide-20
SLIDE 20

Why ¡Neo4j?

Schema-­‑free

  • Complex, ¡densely-­‑connected ¡datasets
slide-21
SLIDE 21

Why ¡Neo4j?

Schema-­‑free

  • Complex, ¡densely-­‑connected ¡datasets

ACID ¡transac2ons

slide-22
SLIDE 22

Why ¡Neo4j?

Schema-­‑free

  • Complex, ¡densely-­‑connected ¡datasets

ACID ¡transac2ons

  • Durable, ¡consistent ¡data
slide-23
SLIDE 23

Why ¡Neo4j?

Schema-­‑free

  • Complex, ¡densely-­‑connected ¡datasets

ACID ¡transac2ons

  • Durable, ¡consistent ¡data

Performance

slide-24
SLIDE 24

Why ¡Neo4j?

Schema-­‑free

  • Complex, ¡densely-­‑connected ¡datasets

ACID ¡transac2ons

  • Durable, ¡consistent ¡data

Performance

  • Millions ¡of ¡‘joins’ ¡per ¡second
slide-25
SLIDE 25

Why ¡Neo4j?

Schema-­‑free

  • Complex, ¡densely-­‑connected ¡datasets

ACID ¡transac2ons

  • Durable, ¡consistent ¡data

Performance

  • Millions ¡of ¡‘joins’ ¡per ¡second
  • Consistent ¡query ¡/mes ¡as ¡dataset ¡grows
slide-26
SLIDE 26
slide-27
SLIDE 27
slide-28
SLIDE 28

from

slide-29
SLIDE 29

stole from

slide-30
SLIDE 30

stole from enemy

slide-31
SLIDE 31

stole from enemy enemy

slide-32
SLIDE 32

stole from enemy enemy enemy

slide-33
SLIDE 33

stole from enemy enemy companion companion enemy

slide-34
SLIDE 34

stole from loves loves enemy enemy companion companion enemy

slide-35
SLIDE 35

stole from loves loves enemy enemy

Victory ¡of ¡ the ¡Daleks

appeared ¡ in appeared ¡ in companion companion enemy

slide-36
SLIDE 36

stole from loves loves enemy enemy

A ¡Good ¡Man ¡ Goes ¡to ¡War

appeared ¡ in appeared ¡ in appeared ¡ in appeared ¡ in

Victory ¡of ¡ the ¡Daleks

appeared ¡ in appeared ¡ in companion companion enemy

slide-37
SLIDE 37

GraphDatabaseService db = new EmbeddedGraphDatabase("/data/drwho");

slide-38
SLIDE 38

GraphDatabaseService db = new EmbeddedGraphDatabase("/data/drwho"); Node theDoctor = db.createNode(); theDoctor.setProperty("name", "The Doctor"); Node daleks = db.createNode(); daleks.setProperty("name", "Daleks"); Node cybermen = db.createNode(); cybermen.setProperty("name", "Cybermen");

slide-39
SLIDE 39

GraphDatabaseService db = new EmbeddedGraphDatabase("/data/drwho"); Node theDoctor = db.createNode(); theDoctor.setProperty("name", "The Doctor"); Node daleks = db.createNode(); daleks.setProperty("name", "Daleks"); Node cybermen = db.createNode(); cybermen.setProperty("name", "Cybermen"); theDoctor.createRelationshipTo(daleks, DynamicRelationshipType.withName("ENEMY")); theDoctor.createRelationshipTo(cybermen, DynamicRelationshipType.withName("ENEMY"));

ENEMY ENEMY

slide-40
SLIDE 40

GraphDatabaseService db = new EmbeddedGraphDatabase("/data/drwho"); Transaction tx = db.beginTx(); try { Node theDoctor = db.createNode(); theDoctor.setProperty("name", "The Doctor"); Node daleks = db.createNode(); daleks.setProperty("name", "Daleks"); Node cybermen = db.createNode(); cybermen.setProperty("name", "Cybermen"); theDoctor.createRelationshipTo(daleks, DynamicRelationshipType.withName("ENEMY")); theDoctor.createRelationshipTo(cybermen, DynamicRelationshipType.withName("ENEMY"));

ENEMY ENEMY

slide-41
SLIDE 41

#neo4j

Cypher

(daleks)<-[:ENEMY]-(doctor)-[:ENEMY]->(cybermen) ENEMY ENEMY

slide-42
SLIDE 42

#neo4j

Cypher

(doctor)-[:ENEMY]->(daleks), (doctor)-[:ENEMY]->(cybermen) ENEMY ENEMY

slide-43
SLIDE 43

#neo4j

CREATE doctor = {name : 'The Doctor'}, daleks = {name : 'Daleks'}, cybermen = {name : 'Cybermen'}, doctor-[:ENEMY]->daleks, doctor-[:ENEMY]->cybermen RETURN doctor; ENEMY ENEMY

Create ¡Graph ¡Using ¡Cypher

slide-44
SLIDE 44

#neo4j

CREATE doctor = {name : 'The Doctor'}, daleks = {name : 'Daleks'}, cybermen = {name : 'Cybermen'}, doctor-[:ENEMY]->daleks, doctor-[:ENEMY]->cybermen RETURN doctor; ENEMY ENEMY

Create ¡Graph ¡Using ¡Cypher

slide-45
SLIDE 45

#neo4j

Dalek ¡Props

hIp://www.dalek6388.co.uk/

slide-46
SLIDE 46

!tle:Power ¡of ¡ the ¡Daleks species:Dalek APPEARED_IN USED_IN props:Daleks name:Dalek ¡Six-­‑5 name:Dalek ¡7 name:Dalek ¡2 name:Dalek ¡1 MEMBER_OF MEMBER_OF type:shoulders type:skirt

slide-47
SLIDE 47
slide-48
SLIDE 48

name:Dalek ¡Six-­‑5 name:Dalek ¡6 name:Dalek ¡5 ORIGINAL_PROP ORIGINAL_PROP ORIGINAL_PROP ORIGINAL_PROP name:Dalek ¡1 name:Dalek ¡2 name:Dalek ¡7

slide-49
SLIDE 49
slide-50
SLIDE 50

!tle:Power ¡of ¡ the ¡Daleks !tle:The ¡ Daleks !tle:The ¡ Dalek ¡ Invasion ¡of ¡ Earth name:Dalek ¡Two-­‑1 name:Dalek ¡One-­‑5 name:Dalek ¡Six-­‑7

name: Dalek ¡Six-­‑5 name:Dalek ¡1 name:Dalek ¡2 name:Dalek ¡7

slide-51
SLIDE 51

#neo4j

Supply ¡Chain ¡Traceability

slide-52
SLIDE 52

daleks episode part

  • riginalprop

APPEARED_IN USED_IN MEMBER_OF COMPOSED_OF ORIGINAL_PROP

slide-53
SLIDE 53

daleks episode part

  • riginalprop

APPEARED_IN USED_IN MEMBER_OF COMPOSED_OF ORIGINAL_PROP

slide-54
SLIDE 54

(daleks)-­‑[:APPEARED_IN]-­‑>(episode)<-­‑[:USED_IN]-­‑

daleks episode part

  • riginalprop

APPEARED_IN USED_IN MEMBER_OF COMPOSED_OF ORIGINAL_PROP

slide-55
SLIDE 55

(daleks)-­‑[:APPEARED_IN]-­‑>(episode)<-­‑[:USED_IN]-­‑ ()<-­‑[:MEMBER_OF]-­‑()-­‑[:COMPOSED_OF]-­‑> ¡

daleks episode part

  • riginalprop

APPEARED_IN USED_IN MEMBER_OF COMPOSED_OF ORIGINAL_PROP

slide-56
SLIDE 56

(daleks)-­‑[:APPEARED_IN]-­‑>(episode)<-­‑[:USED_IN]-­‑ ()<-­‑[:MEMBER_OF]-­‑()-­‑[:COMPOSED_OF]-­‑> ¡ (part)-­‑[:ORIGINAL_PROP]-­‑>(originalprop)

daleks episode part

  • riginalprop

APPEARED_IN USED_IN MEMBER_OF COMPOSED_OF ORIGINAL_PROP

slide-57
SLIDE 57

START ¡ ¡daleks=node:species(species='Dalek') ¡ MATCH ¡ ¡daleks-­‑[:APPEARED_IN]-­‑>episode<-­‑[:USED_IN]-­‑ ¡ ¡ ¡ ¡ ¡ ¡ ¡()<-­‑[:MEMBER_OF]-­‑()-­‑[:COMPOSED_OF]-­‑> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡part-­‑[:ORIGINAL_PROP]-­‑>originalprop RETURN ¡originalprop.name ¡AS ¡prop, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡part.type ¡AS ¡part, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡count(episode) ¡AS ¡episode_count, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡collect(episode.2tle) ¡AS ¡episodes ¡ ORDER ¡BY ¡episode_count ¡desc ¡ LIMIT ¡1;

Cypher Query

slide-58
SLIDE 58

Index Lookup

START ¡ ¡daleks=node:species(species='Dalek') ¡ MATCH ¡ ¡daleks-­‑[:APPEARED_IN]-­‑>episode<-­‑[:USED_IN]-­‑ ¡ ¡ ¡ ¡ ¡ ¡ ¡()<-­‑[:MEMBER_OF]-­‑()-­‑[:COMPOSED_OF]-­‑> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡part-­‑[:ORIGINAL_PROP]-­‑>originalprop RETURN ¡originalprop.name ¡AS ¡prop, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡part.type ¡AS ¡part, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡count(episode) ¡AS ¡episode_count, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡collect(episode.2tle) ¡AS ¡episodes ¡ ORDER ¡BY ¡episode_count ¡desc ¡ LIMIT ¡1;

slide-59
SLIDE 59

Match Nodes & Relationships

START ¡ ¡daleks=node:species(species='Dalek') ¡ MATCH ¡ ¡daleks-­‑[:APPEARED_IN]-­‑>episode<-­‑[:USED_IN]-­‑ ¡ ¡ ¡ ¡ ¡ ¡ ¡()<-­‑[:MEMBER_OF]-­‑()-­‑[:COMPOSED_OF]-­‑> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡part-­‑[:ORIGINAL_PROP]-­‑>originalprop RETURN ¡originalprop.name ¡AS ¡prop, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡part.type ¡AS ¡part, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡count(episode) ¡AS ¡episode_count, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡collect(episode.2tle) ¡AS ¡episodes ¡ ORDER ¡BY ¡episode_count ¡desc ¡ LIMIT ¡1;

slide-60
SLIDE 60

Return Values

START ¡ ¡daleks=node:species(species='Dalek') ¡ MATCH ¡ ¡daleks-­‑[:APPEARED_IN]-­‑>episode<-­‑[:USED_IN]-­‑ ¡ ¡ ¡ ¡ ¡ ¡ ¡()<-­‑[:MEMBER_OF]-­‑()-­‑[:COMPOSED_OF]-­‑> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡part-­‑[:ORIGINAL_PROP]-­‑>originalprop RETURN ¡originalprop.name ¡AS ¡prop, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡part.type ¡AS ¡part, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡count(episode) ¡AS ¡episode_count, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡collect(episode.2tle) ¡AS ¡episodes ¡ ORDER ¡BY ¡episode_count ¡desc ¡ LIMIT ¡1;

slide-61
SLIDE 61

In Webadmin

slide-62
SLIDE 62

#neo4j

The ¡Hardest ¡Working ¡Prop ¡Part

hIp://www.dalek6388.co.uk/ Dalek ¡One’s ¡shoulders

slide-63
SLIDE 63

#neo4j

Download

hIp://neo4j.org/download/

slide-64
SLIDE 64

#neo4j

Tutorial

hIps://github.com/jimwebber/neo4j-­‑tutorial

slide-65
SLIDE 65

#neo4j

Ques/ons?

@iansrobinson ian.robinson@neotechnology.com

slide-66
SLIDE 66

daleks episode part

  • riginalprop

match ¡(daleks)-­‑[:APPEARED_IN]-­‑>(episode)<-­‑[:USED_IN]-­‑ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡()<-­‑[:MEMBER_OF]-­‑()-­‑[:COMPOSED_OF]-­‑> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(part)-­‑[:ORIGINAL_PROP]-­‑>(originalprop) ¡

APPEARED_IN USED_IN MEMBER_OF COMPOSED_OF ORIGINAL_PROP

slide-67
SLIDE 67

daleks episode part

  • riginalprop

match ¡(daleks)-­‑[:APPEARED_IN]-­‑>(episode)<-­‑[:USED_IN]-­‑ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡()<-­‑[:MEMBER_OF]-­‑()-­‑[:COMPOSED_OF]-­‑> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(part)-­‑[:ORIGINAL_PROP]-­‑>(originalprop) ¡

APPEARED_IN USED_IN MEMBER_OF COMPOSED_OF ORIGINAL_PROP