Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Neo4j, connecting the dots

DaFED
August 13, 2015

Neo4j, connecting the dots

DaFED#35
Speaker: Srđan Vranac
Relacione baze podataka se koriste dugi niz godina. Potpuno su stabilne, daju vam fleksibilnost i puno mogućnosti, ali često po ceni performansi. Šta možete da uradite ako imate visoko povezane podatke, nad kojima morate vršiti upite, koji imaju višestruke joine i podupite, naravno da vam rezultati trebaju hitno, tako da upiti koji dugo traju ne dolaze u obzir? Možda je vreme da pogledate graph bazu podataka koja se zove Neo4j i šta ona može da uradi za vas. U ovom predavanju ćemo videti mogućnosti, dobre i loše strane Neo4j-a.

DaFED

August 13, 2015
Tweet

More Decks by DaFED

Other Decks in Technology

Transcript

  1. 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
  2. Databases are great, Databases are fun, Databases make our connected

    world run — Vranac Code4Hire, 2015, DaFed 3
  3. 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
  4. Neo4j Use Cases: • matchmaking • network management • software

    analytics • scientific research • routing Code4Hire, 2015, DaFed 15
  5. 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
  6. Nodes, Relationships, Labels, oh my... CREATE (c:Cake { type: 'Chocolate'

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

    }), (b:Dessert { season: 'Any' }) CREATE (a)-[:IS_TYPE_OF]->(b) Code4Hire, 2015, DaFed 19
  8. Find all Products SQL: SELECT p.* FROM products as p;

    Cypher: MATCH (p:Product) RETURN p; Code4Hire, 2015, DaFed 22
  9. 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
  10. 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
  11. 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
  12. Is that a date or you are just timestamping? 08/03/2015

    @ 2:20pm (UTC) -> 1438611609 Code4Hire, 2015, DaFed 30
  13. 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