Slide 1

Slide 1 text

@michellesanver Graph Databases with PHP and Neo4j AmsterdamPHP

Slide 2

Slide 2 text

About: Michelle Sanver @michellesanver

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

About: Michelle Sanver @michellesanver Zürich, Switzerland (Michelle)-[:LOVES]->(Neo4j)

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

Why graphs? @michellesanver Graph theory has been studied since Leonard Euler’s Bridges 1736 (Michelle)-[:LOVES]->(Neo4j)

Slide 8

Slide 8 text

Why graphs? @michellesanver Graphs are really just connected data… They are everywhere (Michelle)-[:LOVES]->(Neo4j)

Slide 9

Slide 9 text

Why graphs? @michellesanver It’s modern. (Michelle)-[:LOVES]->(Neo4j)

Slide 10

Slide 10 text

Why graphs? @michellesanver Facebook open graph (Michelle)-[:LOVES]->(Neo4j)

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

Graphs vs. Relational databases @michellesanver Relational question: Average age of everyone in this list? Graph question: Who is most likely to hug you here? (Michelle)-[:LOVES]->(Neo4j)

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

Graphs and Neo4j @michellesanver Indexes for easy lookup Type: Person! ! Nick: ! geekie (Michelle)-[:LOVES]->(Neo4j)

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

OmNomHub https://github.com/Omnomhub @michellesanver (Michelle)-[:LOVES]->(Neo4j)

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

OmNomHub @michellesanver Have fun! ;-) (Michelle)-[:LOVES]->(Neo4j)

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

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

Slide 58

Slide 58 text

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

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

Neo4j in PHP @michellesanver (Michelle)-[:LOVES]->(Neo4j) 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 61

Slide 61 text

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

Slide 62

Slide 62 text

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

Slide 63

Slide 63 text

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

Slide 64

Slide 64 text

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

Slide 65

Slide 65 text

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

Slide 66

Slide 66 text

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

Slide 67

Slide 67 text

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

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

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

Slide 71

Slide 71 text

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

Slide 72

Slide 72 text

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

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

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

Slide 75

Slide 75 text

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

Slide 76

Slide 76 text

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

Slide 77

Slide 77 text

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

Slide 78

Slide 78 text

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