Slide 1

Slide 1 text

Neo4j connecting the dots Code4Hire, 2015, DaFed 1

Slide 2

Slide 2 text

business owner, developer, consultant, mercenary, writing terrible code that performs exceptionally, wrangling elePHPants and Pythons, obsessed with process automation, interested in continuous integration and delivery, clean code, testing, best practices and distributed systems Code4Hire, 2015, DaFed 2

Slide 3

Slide 3 text

Databases are great, Databases are fun, Databases make our connected world run — Vranac Code4Hire, 2015, DaFed 3

Slide 4

Slide 4 text

Special cases and snowflakes • Storing structured product information? Store as a document. • Describing how a user got from point A to point B? Follow a graph. Code4Hire, 2015, DaFed 4

Slide 5

Slide 5 text

NoSQL Code4Hire, 2015, DaFed 5

Slide 6

Slide 6 text

Code4Hire, 2015, DaFed 6

Slide 7

Slide 7 text

Nazgûl Code4Hire, 2015, DaFed 7

Slide 8

Slide 8 text

Code4Hire, 2015, DaFed 8

Slide 9

Slide 9 text

NO! Squeal! Code4Hire, 2015, DaFed 9

Slide 10

Slide 10 text

Code4Hire, 2015, DaFed 10

Slide 11

Slide 11 text

Graph? Code4Hire, 2015, DaFed 11

Slide 12

Slide 12 text

7 Bridges of koenigsburg Code4Hire, 2015, DaFed 12

Slide 13

Slide 13 text

From Designer To Developer Code4Hire, 2015, DaFed 13

Slide 14

Slide 14 text

Graph Database Code4Hire, 2015, DaFed 14

Slide 15

Slide 15 text

Neo4j Use Cases: • matchmaking • network management • software analytics • scientific research • routing Code4Hire, 2015, DaFed 15

Slide 16

Slide 16 text

hhhhhhh h:::::h h:::::h h:::::h ccccccccccccccccyyyyyyy yyyyyyyppppp ppppppppp h::::h hhhhh eeeeeeeeeeee rrrrr rrrrrrrrr cc:::::::::::::::c y:::::y y:::::y p::::ppp:::::::::p h::::hh:::::hhh ee::::::::::::ee r::::rrr:::::::::r c:::::::::::::::::c y:::::y y:::::y p:::::::::::::::::p h::::::::::::::hh e::::::eeeee:::::eer:::::::::::::::::r c:::::::cccccc:::::c y:::::y y:::::y pp::::::ppppp::::::ph:::::::hhh::::::h e::::::e e:::::err::::::rrrrr::::::r c::::::c ccccccc y:::::y y:::::y p:::::p p:::::ph::::::h h::::::he:::::::eeeee::::::e r:::::r r:::::r c:::::c y:::::y y:::::y p:::::p p:::::ph:::::h h:::::he:::::::::::::::::e r:::::r rrrrrrr c:::::c y:::::y:::::y p:::::p p:::::ph:::::h h:::::he::::::eeeeeeeeeee r:::::r c::::::c ccccccc y:::::::::y p:::::p p::::::ph:::::h h:::::he:::::::e r:::::r c:::::::cccccc:::::c y:::::::y p:::::ppppp:::::::ph:::::h h:::::he::::::::e r:::::r c:::::::::::::::::c y:::::y p::::::::::::::::p h:::::h h:::::h e::::::::eeeeeeee r:::::r cc:::::::::::::::c y:::::y p::::::::::::::pp h:::::h h:::::h ee:::::::::::::e r:::::r cccccccccccccccc y:::::y p::::::pppppppp hhhhhhh hhhhhhh eeeeeeeeeeeeee rrrrrrr y:::::y p:::::p y:::::y p:::::p y:::::y p:::::::p y:::::y p:::::::p yyyyyyy p:::::::p ppppppppp Code4Hire, 2015, DaFed 16

Slide 17

Slide 17 text

Nodes, Relationships, Labels, oh my... Code4Hire, 2015, DaFed 17

Slide 18

Slide 18 text

Nodes, Relationships, Labels, oh my... CREATE (c:Cake { type: 'Chocolate' }) RETURN c CREATE (d:Dessert { season: 'Any' }) RETURN d Code4Hire, 2015, DaFed 18

Slide 19

Slide 19 text

Nodes, Relationships, Labels, oh my... MATCH (a:Cake { type: 'Chocolate' }), (b:Dessert { season: 'Any' }) CREATE (a)-[:IS_TYPE_OF]->(b) Code4Hire, 2015, DaFed 19

Slide 20

Slide 20 text

Voilà Code4Hire, 2015, DaFed 20

Slide 21

Slide 21 text

Comparative Examples Code4Hire, 2015, DaFed 21

Slide 22

Slide 22 text

Find all Products SQL: SELECT p.* FROM products as p; Cypher: MATCH (p:Product) RETURN p; Code4Hire, 2015, DaFed 22

Slide 23

Slide 23 text

Field Access, Ordering and Paging SQL: SELECT p.ProductName, p.UnitPrice FROM products as p ORDER BY p.UnitPrice DESC LIMIT 10; Cypher: MATCH (p:Product) RETURN p.productName, p.unitPrice ORDER BY p.unitPrice DESC LIMIT 10; Code4Hire, 2015, DaFed 23

Slide 24

Slide 24 text

Joining Products with Customers SQL: SELECT distinct c.CompanyName FROM customers AS c JOIN orders AS o ON (c.CustomerID = o.CustomerID) JOIN order_details AS od ON (o.OrderID = od.OrderID) JOIN products as p ON (od.ProductID = p.ProductID) WHERE p.ProductName = 'Chocolade'; Code4Hire, 2015, DaFed 24

Slide 25

Slide 25 text

Joining Products with Customers Cypher: MATCH (p:Product {productName:"Chocolade"})<-[:PRODUCT]- (:Order)<-[:PURCHASED]-(c:Customer) RETURN distinct c.companyName; Code4Hire, 2015, DaFed 25

Slide 26

Slide 26 text

Hierarchies and Trees, Variable Length Joins SQL: SELECT p.ProductName FROM Product as p JOIN ProductCategory pc ON (p.CategoryID = pc.CategoryID AND pc.CategoryName = "Dairy Products") JOIN ProductCategory pc1 ON (p.CategoryID = pc1.CategoryID JOIN ProductCategory pc2 ON (pc2.ParentID = pc2.CategoryID AND pc2.CategoryName = "Dairy Products") JOIN ProductCategory pc3 ON (p.CategoryID = pc3.CategoryID JOIN ProductCategory pc4 ON (pc3.ParentID = pc4.CategoryID) JOIN ProductCategory pc5 ON (pc4.ParentID = pc5.CategoryID AND pc5.CategoryName = "Dairy Products") ; Code4Hire, 2015, DaFed 26

Slide 27

Slide 27 text

Hierarchies and Trees, Variable Length Joins Cypher: MATCH (p:Product)-[:CATEGORY]->(l:ProductCategory)-[:PARENT*0..]- (:ProductCategory {name:"Dairy Products"}) RETURN p.name Code4Hire, 2015, DaFed 27

Slide 28

Slide 28 text

Demo Time Code4Hire, 2015, DaFed 28

Slide 29

Slide 29 text

The bad & The Ugly Code4Hire, 2015, DaFed 29

Slide 30

Slide 30 text

Is that a date or you are just timestamping? 08/03/2015 @ 2:20pm (UTC) -> 1438611609 Code4Hire, 2015, DaFed 30

Slide 31

Slide 31 text

Import Data CREATE CONSTRAINT ON (deal:Deal) ASSERT deal.id IS UNIQUE; USING PERIODIC COMMIT 5000 LOAD CSV WITH HEADERS FROM "file:///Users/vranac/dev/deals/temp/deals_100k.csv" AS row WITH row MERGE (d:Deal {Id: row.id}) ON CREATE SET d.Id = row.id, d.a = row.a, d.b = row.b, ON MATCH SET d.a = row.a, d.b = row.b, ; Code4Hire, 2015, DaFed 31

Slide 32

Slide 32 text

Long queries timeout Code4Hire, 2015, DaFed 32

Slide 33

Slide 33 text

The End Thank You! Questions? Code4Hire, 2015, DaFed 33