Slide 1

Slide 1 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4J is AWESOME!

Slide 2

Slide 2 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver

Slide 3

Slide 3 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver WIIIIIIIE \o/ “Learn the most by sharing your knowledge with others” - @coderabbi

Slide 4

Slide 4 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver This talk is entry-level.

Slide 5

Slide 5 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver

Slide 6

Slide 6 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver

Slide 7

Slide 7 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Michelle Sanver

Slide 8

Slide 8 text

@michellesanver (Michelle)-[:LOVES]->(Neo4j) Michelle Sanver Co-President of PHPWomen

Slide 9

Slide 9 text

@michellesanver (Michelle)-[:LOVES]->(Neo4j) Michelle Sanver Accent(s)!?

Slide 10

Slide 10 text

@michellesanver (Michelle)-[:LOVES]->(Neo4j) Michelle Sanver

Slide 11

Slide 11 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver I’m a backend developer.

Slide 12

Slide 12 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Setting expectations

Slide 13

Slide 13 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver How I got into Neo4j

Slide 14

Slide 14 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs \o/

Slide 15

Slide 15 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs \o/ Graph theory has been studied since Leonard Euler’s Bridges 1736

Slide 16

Slide 16 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs \o/ Body Text

Slide 17

Slide 17 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs \o/

Slide 18

Slide 18 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs \o/ Graphs are really just connected data… They are everywhere

Slide 19

Slide 19 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs \o/

Slide 20

Slide 20 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs \o/ It’s modern.

Slide 21

Slide 21 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs \o/ Facebook open graph

Slide 22

Slide 22 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs \o/ A graph is an easy way to visualise connected data. Michelle Graphs likes

Slide 23

Slide 23 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Relational question: Average age of everyone in this list? Graph question: Who knows me from third parties?

Slide 24

Slide 24 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Relational databases have tables Recipes

Slide 25

Slide 25 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Tables have relationships Recipes Groups

Slide 26

Slide 26 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Which causes a join table… Recipes Groups RecipeToGroup

Slide 27

Slide 27 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases You query via the table Recipes Groups RecipeToGroup

Slide 28

Slide 28 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Imagine having *actual* relations Pasta group Spaghetti Italian group

Slide 29

Slide 29 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Recipes Groups RecipeToGroup Pasta group Spaghetti Italian group

Slide 30

Slide 30 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Relational databases have a structure

Slide 31

Slide 31 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Neo4j has no schema

Slide 32

Slide 32 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases A big query. The EAV model.

Slide 33

Slide 33 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases SET @entityid = '3'; SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'varchar' AS 'type' FROM catalog_category_entity e JOIN catalog_category_entity_varchar eav ON e.entity_id = eav.entity_id JOIN eav_attribute ea ON eav.attribute_id = ea.attribute_id WHERE e.entity_id = @entityid UNION SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'int' AS 'type' FROM catalog_category_entity e JOIN catalog_category_entity_int eav ON e.entity_id = eav.entity_id JOIN eav_attribute ea ON eav.attribute_id = ea.attribute_id WHERE e.entity_id = @entityid UNION

Slide 34

Slide 34 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'decimal' AS 'type' FROM catalog_category_entity e JOIN catalog_category_entity_decimal eav ON e.entity_id = eav.entity_id JOIN eav_attribute ea ON eav.attribute_id = ea.attribute_id WHERE e.entity_id = @entityid UNION selecting ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'datetime' AS 'type' FROM catalog_category_entity e JOIN catalog_category_entity_datetime eav ON e.entity_id = eav.entity_id JOIN eav_attribute ea ON eav.attribute_id = ea.attribute_id WHERE e.entity_id = @entityid UNION SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'text' AS 'type' FROM catalog_category_entity e JOIN catalog_category_entity_text eav ON e.entity_id = eav.entity_id JOIN eav_attribute ea ON eav.attribute_id = ea.attribute_id WHERE e.entity_id = @entityid

Slide 35

Slide 35 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Having a flexible schema database costs a lot.

Slide 36

Slide 36 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases For modern complex data…

Slide 37

Slide 37 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs vs. Relational databases Would you still pick a relational structure?

Slide 38

Slide 38 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j

Slide 39

Slide 39 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver neo4j.org

Slide 40

Slide 40 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver neotechnology.com

Slide 41

Slide 41 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Java Based

Slide 42

Slide 42 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Open Source! github.com/neo4j

Slide 43

Slide 43 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Meetups everywhere neo4j.meetup.com

Slide 44

Slide 44 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j Graphs have…

Slide 45

Slide 45 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j ( Nodes )

Slide 46

Slide 46 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j (Node) { Properties } As many as you want Type: Person Nick: geekie Type: Person Nick: WyriHaximus

Slide 47

Slide 47 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j (Node) [ Relationships ] As many as you want Type: Person Nick: geekie Type: Person Nick: WyriHaximus

Slide 48

Slide 48 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j Nick: geekie Nick: WyriHaximus knows (Node) [ Relationships ] As many as you want

Slide 49

Slide 49 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j Labels Type: Person Nick: geekie

Slide 50

Slide 50 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j Indexes for easy lookup

Slide 51

Slide 51 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j Common named graphs

Slide 52

Slide 52 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j Common named graphs Local McLaughlin graph

Slide 53

Slide 53 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j Common named graphs Diamond Butterfly Bull Franklin Tutte Wagner

Slide 54

Slide 54 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Graphs and Neo4j You can make art out of your DB. (Don’t)

Slide 55

Slide 55 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub

Slide 56

Slide 56 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub Like GitHub but for recipes!

Slide 57

Slide 57 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub Fork a recipe

Slide 58

Slide 58 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub See all forks

Slide 59

Slide 59 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub Join groups

Slide 60

Slide 60 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub Search similar recipes

Slide 61

Slide 61 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub Honestly… It’s just a pet project.

Slide 62

Slide 62 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j architecture

Slide 63

Slide 63 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j architecture Disks File System Cache Record Files Object Cache Cypher Core API Traversal API Transaction Management Transaction Log

Slide 64

Slide 64 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Hang in there

Slide 65

Slide 65 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j architecture: Traversals

Slide 66

Slide 66 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Traversals Pathexpanders: Define what to traverse

Slide 67

Slide 67 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Traversals Order: Depth-first or breadth-first.

Slide 68

Slide 68 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Traversals Uniqueness : Visit once.

Slide 69

Slide 69 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Traversals Evaluator : Should I stay or should I go?

Slide 70

Slide 70 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Traversals Starting nodes: And so it begins.

Slide 71

Slide 71 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j architecture: Cypher and Browser

Slide 72

Slide 72 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Cypher Cypher: SQL for graph databases.

Slide 73

Slide 73 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Cypher ) Parentheses means nodes (Or hugs) (

Slide 74

Slide 74 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Cypher } Curly braces means properties {

Slide 75

Slide 75 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Cypher ] Square brackets means relationships [

Slide 76

Slide 76 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Browser Makes it easy to visualise and query the data.

Slide 77

Slide 77 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Browser Let’s learn cypher in the browser!

Slide 78

Slide 78 text

DEMO: Cypher and Browser (Michelle)-[:LOVES]->(Neo4j) @michellesanver

Slide 79

Slide 79 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j architecture Neostore File Storage

Slide 80

Slide 80 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neostore Several different store files

Slide 81

Slide 81 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neostore Each store has specific data

Slide 82

Slide 82 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neostore Nodes neostore.nodestore.db 9 bytes

Slide 83

Slide 83 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neostore Nodes in-use key: 1 byte

Slide 84

Slide 84 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neostore Fixed size == FAST

Slide 85

Slide 85 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neostore Relationships neostore.relationshipstore.db 33 bytes

Slide 86

Slide 86 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neostore Properties neostore.propertystore.db neostore.propertystore.db.index neostore.propertystore.db.strings neostore.propertystore.db.arrays

Slide 87

Slide 87 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Hardware matters!

Slide 88

Slide 88 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Caching in memory, or filesystem

Slide 89

Slide 89 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP

Slide 90

Slide 90 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP As we saw There’s a REST interface!

Slide 91

Slide 91 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP Neo4jPHP PHP Wrapper for the Neo4j graph database REST interface github.com/jadell/neo4jphp

Slide 92

Slide 92 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP require('vendor/autoload.php'); $client = new Everyman\Neo4\Client('localhost', 7474); print_r($client->getServerInfo());

Slide 93

Slide 93 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP Use $client to do anything!

Slide 94

Slide 94 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP Creating a node with the client $recipe = $client->makeNode(); $recipe->setProperty('title', ‘Spaghetti Bolognese') ->setProperty('Description', ‘Italian words') ->setProperty('Ingredients', ‘A lot') ->save(); $recipe->getId();

Slide 95

Slide 95 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP You get the idea, it’s well documented! Use $client to do anything, even Cypher queries. https://github.com/jadell/neo4jphp/wiki

Slide 96

Slide 96 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP In OmNomHub we’re using Symfony2 There’s a bundle for that. https://github.com/klaussilveira/neo4j-client-bundle

Slide 97

Slide 97 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub: The Future

Slide 98

Slide 98 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub: The Future Connecting users “You both like”

Slide 99

Slide 99 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub: The Future Connecting recipes “These have similar ingredients and user base”

Slide 100

Slide 100 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub: The Future Being smart “You might like”

Slide 101

Slide 101 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub: The Future Being smart Smart recipe collections!

Slide 102

Slide 102 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub: The Future Being creepy “Don’t like meat huh?”

Slide 103

Slide 103 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Wrapup

Slide 104

Slide 104 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Wrapup Graphs are everywhere

Slide 105

Slide 105 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Wrapup They make it easy to connect data

Slide 106

Slide 106 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Wrapup Easier to be creepy <3

Slide 107

Slide 107 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Wrapup OmNomHub will be EPIC :D

Slide 108

Slide 108 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Wrapup Open Source! https://github.com/Omnomhub

Slide 109

Slide 109 text

Resources (Michelle)-[:LOVES]->(Neo4j) @michellesanver docs.neo4j.org Graph Databases - Ian Robinson, 
 neo technology gives you the e-book version for free. neo4j.org/learn

Slide 110

Slide 110 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Thank you!

Slide 111

Slide 111 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Questions?

Slide 112

Slide 112 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver How would you use it?