Hands on Neo4j 2.0
-
Upload
weareesynergy -
Category
Technology
-
view
176 -
download
7
description
Transcript of Hands on Neo4j 2.0
Hands on Neo4j 2.0
Dr. Jim Webber!Chief Scientist, Neo Technology!
@jimwebber
roadmap• where we are (mostly)
• imprisoned data
• a little history
• labeled property graph model
• connected data
• using a whiteboard
http://flickr.com/photos/23465812@N00/7898643042 by davecito, CC BY
Neo Technology, Inc Confidential Drupal8 Schema - Copyright drupal.org
Neo Technology, Inc Confidential
TABLES?
ARGGHHH
Neo Technology, Inc Confidentialhttp://flickr.com/photos/keepingtime_ca/8490224742 by keepingtime_ca, CC BY
Neo Technology, Inc ConfidentialBy AgnosticPreachersKid (Own work) [CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons
Neo Technology, Inc Confidential http://flickr.com/photos/rueful/5917659410/ by Kiran Foster, CC BY
“There is a significant downside - the whole approach works really well when data access is aligned with the aggregates, but what if you want to look at the data in a different way? Order entry naturally stores orders as
aggregates, but analyzing product sales cuts across the aggregate structure. The advantage of not using an aggregate structure in the
database is that it allows you to slice and dice your data different ways for different audiences.
!
This is why aggregate-oriented stores talk so much about map-reduce.”
– Martin Fowler, http://martinfowler.com/bliki/AggregateOrientedDatabase.html
Neo Technology, Inc Confidentialhttp://flickr.com/photos/wwworks/5319295174 by woodleywonderworks, CC BY
Neo Technology, Inc Confidential Copyright TFL (Transport For London)
Leonhard Euler(1707 - 1783)
Image by Jakob Emanuel Handmann [Public domain], via Wikimedia Commons
Neo Technology, Inc Confidential Image is US Public Domain
A
B
D
C
A
B
D
C
http://flickr.com/photos/samchurchill/8022804713 by Sam Churchill, CC BY
Copyright Facebook
[CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons
By Euan Richard (Own work) [CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons
% of People Who Hate Michael Jackson by Date
0
25
50
75
100
June 25, 2009 June 26,2009
Not a Graph
Customers AccountsCustomer_Accounts
143 Alice
143 326
143 725
143 981
326 $100
725 $632
981 $212
name: Alice
bal: $100
bal: $632
bal: $212
Nodes
Relationships
owns
owns
owns
Customer
Account
Account
Account
Labeled Property Graph Model
• Nodes with optional labels and optional properties
• Named, directed Relationships with optional properties
(Relationships have exactly one start and one end node, which may be the same node)
modelingstart with a whiteboard
Flight_Delayid
flight_iddelay_timereason_id
Airportid
namecity_id
Cityid
name
Flightid
dateflight_number
origin_airport_iddestination_airport_idscheduled_departure
scheduled_arrivalReason
idname
Flight_Diversionid
flight_idairport_id
SELECT r.name as reason, count(*) as result_count FROM Flight f INNER JOIN Airport o ON Airport.id = Flight.origin_airport_id, INNER JOIN Airport d ON Airport.id = Flight.destination_airport_id, INNER JOIN Flight_Delay fd ON Airport.id = Flight_Delay.flight_id INNER JOIN Reason r ON Flight_Delay.reason_id = Reason.id WHERE o.name = "SFO" AND d.name = "JFK" GROUP BY r.name ORDER BY result_count DESC
Fail
(o)<-[:ORIGIN]-(f) (f)-[:
DESTIN
ATION]
->(d)
(f)-[:CANCELLED_BY]->(r)
(o)<-[:ORIGIN]-(f) (f)-[:DESTINATION]->(d)
(f)-[:CANCELLED_BY]->(r)
MATCH , ,
WHERE o.code = "SFO" AND d.code = "JFK"
RETURN r.name AS reason, count(*) AS count
ORDER BY count DESC
MATCH (o)<-[:ORIGIN]-(f)-[:DESTINATION]->(d),
(f)-[:CANCELLED_BY]->(r)
WHERE o.code = "SFO" AND d.code = "JFK"
RETURN r.name AS reason, count(*) AS count
ORDER BY count DESC
MATCH (customer)-‐[:BOUGHT]-‐>()-‐[:IN*]-‐>(:Category {name:'Baby'}),
(customer)-‐[:BOUGHT]-‐>()-‐[:IN*]-‐>(:Category {name:'Beer'})
WHERE NOT (customer)-‐[:BOUGHT]-‐>()-‐[:IN*]-‐>(:Category {name:'Console'})
RETURN customer
A Demo?Using Neo4j 2.0.3 for Retail Analytics in minutes
What’s Neo4j good for?• Recommendations
• Social networks
• Content Management
• MDM / System-of-Record
• Product Catalogue
• Financial Audit / Modeling
• Business intelligence
• Data centre management
• Supply chain/provenance
• Routing
• Web of things
• Time series/event data
• Web analytics, user journeys
• Scientific computing
• Spatial
• Geo/Seismic/Meteorological
• Bio/Pharma
• And much, much more…
Aviation
Finance
Accenture
AerospaceEnergy
Software Financial Telecoms Health Web / Social Media Education, Logistics,
Government
Network & Data Center
MDM / SystemOf Record
Social
Geo
Recommendations
Identity &Access Control
ContentManagement
Business Intel.,Audit, CRM
Resources
• Graph Databases Book (O’Reilly)
• Full, free eBook version available:http://graphdatabases.com
• New, free online training:
• http://www.neo4j.org/learn/online_course