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

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 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 33

Slide 33 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', 'datetim '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 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 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub An idea for a different recipe website

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub Join groups and share recipe collections among them

Slide 57

Slide 57 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub Have your own private recipe collections

Slide 58

Slide 58 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver OmNomHub Search similar recipes (This is a part where the graph structure shines)

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

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

Slide 61

Slide 61 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 62

Slide 62 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 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 Neo4j architecture Disks File System Cache Record Files Object Cache Cypher Core API Traversal API Transaction Management Transaction Log

Slide 65

Slide 65 text

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

Slide 66

Slide 66 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 67

Slide 67 text

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

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

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

Slide 71

Slide 71 text

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

Slide 72

Slide 72 text

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

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

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

Slide 75

Slide 75 text

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

Slide 76

Slide 76 text

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

Slide 77

Slide 77 text

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

Slide 78

Slide 78 text

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

Slide 79

Slide 79 text

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

Slide 80

Slide 80 text

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

Slide 81

Slide 81 text

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

Slide 82

Slide 82 text

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

Slide 83

Slide 83 text

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

Slide 84

Slide 84 text

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

Slide 85

Slide 85 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP There is an actively maintained Drupal module for Drupal 7 and 8. https://www.drupal.org/project/neo4j

Slide 86

Slide 86 text

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

Slide 87

Slide 87 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP GraphAware PHP Client https://github.com/graphaware/neo4j-php-client

Slide 88

Slide 88 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP $client = ClientBuilder::create()
 ->addConnection('bolt', 'bolt://neo4j:password@localhost:7687')
 ->build(); 
 $query = "MATCH (n:User) RETURN n";
 $result = $client->run($query);
 
 foreach ($result->getRecords() as $record) {
 echo(count($record->value('name'));
 }


Slide 89

Slide 89 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP $client = ClientBuilder::create()
 ->addConnection('bolt', 'bolt://neo4j:password@localhost:7687')
 ->build(); 
 $query = "MATCH (n:User) RETURN n";
 $result = $client->run($query);
 
 foreach ($result->getRecords() as $record) {
 echo(count($record->value('name'));
 }


Slide 90

Slide 90 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP $client = ClientBuilder::create()
 ->addConnection('bolt', 'bolt://neo4j:password@localhost:7687')
 ->build(); 
 $query = "MATCH (n:User) RETURN n";
 $result = $client->run($query);
 
 foreach ($result->getRecords() as $record) {
 echo(count($record->value('name'));
 }


Slide 91

Slide 91 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP $client = ClientBuilder::create()
 ->addConnection('bolt', 'bolt://neo4j:password@localhost:7687')
 ->build(); 
 $query = "MATCH (n:User) RETURN n";
 $result = $client->run($query);
 
 foreach ($result->getRecords() as $record) {
 echo(count($record->value('name'));
 }


Slide 92

Slide 92 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP GraphAware also released an OGM

Slide 93

Slide 93 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP /**
 * @OGM\GraphId()
 * @var int
 */
 protected $id;
 
 /**
 * @OGM\Property(type="string")
 * @var string
 */
 protected $recipeName;
 
 /**
 * @OGM\Relationship(type="FORKED", direction="OUTGOING", targetEntity="User", collection=true)
 * @var ArrayCollection|User[]
 */
 protected $users;

Slide 94

Slide 94 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP /**
 * @OGM\GraphId()
 * @var int
 */
 protected $id;
 
 /**
 * @OGM\Property(type="string")
 * @var string
 */
 protected $recipeName;
 
 /**
 * @OGM\Relationship(type="FORKED", direction="OUTGOING", targetEntity="User", collection=true)
 * @var ArrayCollection|User[]
 */
 protected $users;

Slide 95

Slide 95 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP /**
 * @OGM\GraphId()
 * @var int
 */
 protected $id;
 
 /**
 * @OGM\Property(type="string")
 * @var string
 */
 protected $recipeName;
 
 /**
 * @OGM\Relationship(type="FORKED", direction="OUTGOING", targetEntity="User", collection=true)
 * @var ArrayCollection|User[]
 */
 protected $users;

Slide 96

Slide 96 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP /**
 * @OGM\GraphId()
 * @var int
 */
 protected $id;
 
 /**
 * @OGM\Property(type="string")
 * @var string
 */
 protected $recipeName;
 
 /**
 * @OGM\Relationship(type="FORKED", direction="OUTGOING", targetEntity="User", collection=true)
 * @var ArrayCollection|User[]
 */
 protected $users;

Slide 97

Slide 97 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP $user = $em->getRepository(User::class)- >findOneBy('name', 'Michelle');

Slide 98

Slide 98 text

(Michelle)-[:LOVES]->(Neo4j) @michellesanver Neo4j in PHP It is well documented https://neo4j.com/developer/php/ https://github.com/graphaware/neo4j-php-client https://github.com/graphaware/neo4j-php-ogm

Slide 99

Slide 99 text

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

Slide 100

Slide 100 text

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

Slide 101

Slide 101 text

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

Slide 102

Slide 102 text

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

Slide 103

Slide 103 text

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

Slide 104

Slide 104 text

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

Slide 105

Slide 105 text

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

Slide 106

Slide 106 text

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

Slide 107

Slide 107 text

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

Slide 108

Slide 108 text

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

Slide 109

Slide 109 text

Resources (Michelle)-[:LOVES]->(Neo4j) @michellesanver neo4j.org/learn https://neo4j.com/developer/php/ https://www.drupal.org/project/neo4j

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?