1 Chapter 5 Graphs of Linear Functions. 2 Section 5.2 Graphs of Linear Functions.
The 5 Graphs of Love
-
Upload
neo4j-the-open-source-graph-database -
Category
Technology
-
view
1.847 -
download
0
description
Transcript of The 5 Graphs of Love
![Page 1: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/1.jpg)
�1
Amanda Laucher Neo Technology @pandamonial
(Neo4j)-[:POWERS] ->(Love)
![Page 2: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/2.jpg)
�2
Most of your favorite dating sites
![Page 3: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/3.jpg)
�3
The 5 Graphs of Love
![Page 4: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/4.jpg)
�4
The 5 Graphs of Love
• The Friends-of-Friends Graph
!
!
!
!
!
!
!
![Page 5: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/5.jpg)
�5
The 5 Graphs of Love
• The Friends-of-Friends Graph
!
• The Passion Graph
!
!
!
!
!
![Page 6: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/6.jpg)
�6
The 5 Graphs of Love
• The Friends-of-Friends Graph
!
• The Passion Graph
!
• The Location Graph
!
!
!
![Page 7: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/7.jpg)
�7
The 5 Graphs of Love
• The Friends-of-Friends Graph
!
• The Passion Graph
!
• The Location Graph
!
• The Safety Graph
!
![Page 8: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/8.jpg)
�8
The 5 Graphs of Love
• The Friends-of-Friends Graph
!
• The Passion Graph
!
• The Location Graph
!
• The Safety Graph
!
• The Poser Graph
![Page 9: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/9.jpg)
๏from: California
๏appearance: very handsome
๏personality: super friendly nerd
๏interests: piano, coding
Meet Jeremy...
Jeremy
![Page 10: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/10.jpg)
๏Kerstin: his sister
๏Peter: his buddy
๏Andreas: his coworker
Jeremy has some friends
KerstinAndreas
JeremyPeter
![Page 11: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/11.jpg)
๏Michael: master hacker, divorced, 2 kids
๏Johan: technology sage, likes fast cars
๏Madelene: polyglot journalist, loves dogs
๏Allison: marketing maven, likes long walks on the beach
His friends introduced more friends
Johan
Kerstin
Allison
Andreas
Michael
Madelene
JeremyPeter
![Page 12: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/12.jpg)
๏how do we know they are friends?
๏either ask each pair: are you friends?
๏or, we can add explicit connections
๏Twitter, Facebook, LinkedIn, etc.
So, we have a bunch of people
Johan
Kerstin
Allison
Andreas
Michael
Madelene
JeremyPeter
![Page 13: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/13.jpg)
๏it's just a graph
This is really just data
Johan
Kerstin
Allison
AnnaAdamAndreas
Michael
Madelene
JeremyPeter
![Page 14: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/14.jpg)
�14
A graph?
![Page 15: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/15.jpg)
Yes, a graph...
�15
๏you know the common data structures
•linked lists, trees, object "graphs"
๏a graph is the general purpose data structure
•suitable for any connected data
๏well-understood patterns and algorithms
•studied since Leonard Euler's 7 Bridges (1736)
•Codd's Relational Model (1970)
•not a new idea, just an idea who's time is now
![Page 16: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/16.jpg)
�16
How can you use this? With a Graph Database
![Page 17: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/17.jpg)
A graph database...
�17
๏optimized for the connections between records
๏really, really fast at querying across records
๏a database: transactional with the usual operations
๏“A relational database may tell you the average age of everyone here,
but a graph database will tell you who is most likely to buy you a beer later.”
![Page 18: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/18.jpg)
What’s love got to do with it?
�18
![Page 19: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/19.jpg)
�19
Friends of Friends Graph
![Page 20: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/20.jpg)
!
๏4% likelihood of interacting with a stranger
๏10% likelihood of interacting with friend of friend
๏7% chance of interacting with 3rd degree connection (friend of friend of friend)
๏Connections mean a much larger number of interactions!
JeremyPeterJohan
Jennifer
Allison
AnnaAdamAndreas
Michael
Madelene
According to SNAP Interactive if you are a female user, you have a:
![Page 21: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/21.jpg)
�21
Friends of friends = larger dating pool
![Page 22: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/22.jpg)
Friends
Peter JenniferAndreasJeremy
![Page 23: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/23.jpg)
Friends of friends
PeterJohan
Jennifer
Allison
Andreas
Jeremy
MadeleneFrank
Amanda
Jeremy
![Page 24: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/24.jpg)
Friends of friends of friends
![Page 25: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/25.jpg)
�25
Find Jeremy’s FoFs
![Page 26: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/26.jpg)
�26
Demo - Find who Jeremy shares the most friends with
![Page 27: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/27.jpg)
JakePeter JenniferAndreas
:WORKS_FOR:FRIENDS:FRIENDS
Complicated Relationships
![Page 28: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/28.jpg)
:WANTS_TO_DATE
JakePeter JenniferAndreas
:WORKS_FOR:FRIENDS:FRIENDS
Friends
![Page 29: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/29.jpg)
Awkward!!
JakePeter JenniferAndreas
:WORKS_FOR:FRIENDS:FRIENDS
Friends
:WANTS_TO_DATE
![Page 30: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/30.jpg)
:WANTS_TO_DATE
Awkward
:WANTS_TO_DATE
JakePeter JenniferAndreas
:WORKS_FOR:FRIENDS:FRIENDS
Friends of Friends
![Page 31: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/31.jpg)
:WANTS_TO_DATE
:WANTS_TO_DATE
JakePeter JenniferAndreas
:WORKS_FOR:FRIENDS:FRIENDS
:NO_DATE
Too complex!
Friends of Friends
![Page 32: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/32.jpg)
Friends of Friends of Friends
:WANTS_TO_DATE :WANTS_TO_DATE
JakePeter JenniferAndreas
:WORKS_FOR:FRIENDS:FRIENDS
:NO_DATE
:NO_DATE
:WANTS_TO_DATE
:WANTS_TO_DATE
![Page 33: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/33.jpg)
Friends of Friends of Friends
![Page 34: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/34.jpg)
Friends of Friends of Friends
![Page 35: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/35.jpg)
๏from: UK
๏seeking: Females
๏appearance: Hot, hot, hot!
๏personality: Fun loving, easy going
๏interests: cooking, chemistry
Jon
Meet Jon...
![Page 36: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/36.jpg)
�36
Location Graph
![Page 37: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/37.jpg)
Jon wants to find a date and refuses to have a long distance relationship
�37
![Page 38: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/38.jpg)
�38
Location Graph*Neo4j Spatial
![Page 39: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/39.jpg)
�39
Passion Graph
![Page 40: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/40.jpg)
Jon wants to find someone he can share his passions
with.
�40
![Page 41: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/41.jpg)
Jon
:REPORTED_INTEREST
Match Specific Interests
Cooking
![Page 42: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/42.jpg)
Jon
:REPORTED_INTEREST
Match Specific Interests
![Page 43: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/43.jpg)
Jon
:REPORTED_INTEREST
JenniferAnne Julia
Match Specific Interests
![Page 44: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/44.jpg)
�44
Safety Graph
![Page 45: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/45.jpg)
Jon uses social networks
Jon
![Page 46: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/46.jpg)
Let’s dig into his Twitter
![Page 47: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/47.jpg)
He follows some strange people
![Page 48: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/48.jpg)
…and tweets about strange things!
![Page 49: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/49.jpg)
Some basic word analysis
![Page 50: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/50.jpg)
Let’s update based on behavior
:DEMONSTRATED_INTEREST
Jon
![Page 51: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/51.jpg)
Any ladies ok with this?
![Page 52: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/52.jpg)
Jennifer Jane Maria
Any ladies ok with this?
![Page 53: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/53.jpg)
�53
Passion Graph
![Page 54: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/54.jpg)
Jon loves the New England Patriots
�54
Jon:HAS_INTEREST
![Page 55: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/55.jpg)
�55
Sports
:IS_A
:IS_A
:IS_A:IS_A
![Page 56: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/56.jpg)
�56
Sports
:HAS_TEAM
:HAS_TEAM
:HAS_TEAM
:HAS_TEAM
:HAS_TEAM
:IS_A:IS_A
:IS_A
:IS_A
![Page 57: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/57.jpg)
�57
Sports
:HAS_TEAM
:HAS_TEAM
:HAS_TEAM
:HAS_TEAM
:HAS_TEAM
:IS_A:IS_A
:IS_A
:IS_A
Jon
![Page 58: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/58.jpg)
�58
Sports
Jon
![Page 59: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/59.jpg)
�59
Find ladies who like football
![Page 60: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/60.jpg)
�60
Jennifer Katie Greta
Find ladies who like football
![Page 61: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/61.jpg)
�61
Poser Graph
![Page 62: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/62.jpg)
Jon has no luck with online dating. All of his interactions are with
spam profiles.
�62
![Page 63: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/63.jpg)
Find real people with at least 1 social network & minimum 2 posts
�63
![Page 64: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/64.jpg)
�64
Find ladies who aren’t spam bots
![Page 65: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/65.jpg)
Put it all together
�65
![Page 66: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/66.jpg)
�66
Find Jon’s perfect date
![Page 67: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/67.jpg)
�67
JenniferJon:PERFECT_FOR
![Page 68: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/68.jpg)
�68
JenniferJon:HAS_DATE_WITH
![Page 69: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/69.jpg)
�69
Jon & Jennifer delete their profiles and go off into the sunset!
JenniferJon
![Page 70: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/70.jpg)
Jon Jennifer
Love
[:FOUND]
[:AIDS]
[:AIDS]
[:AIDS]
[:AIDS]
[:AIDS][:POWERS]
![Page 71: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/71.jpg)
�71
Amanda Laucher Neo Technology
(Neo4j)-[:POWERS] ->(Love)
![Page 72: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/72.jpg)
RDBMS/Other vs. Native Graph Database
Performance Challenges with Connected Data
Connectedness of Data Set
Resp
onse
Tim
e
RDBMS / Other NOSQL# Hops: 0-2 Degree: < 3
Size: ThousandsNeo4j
# Hops: Tens to Hundreds Degree: Thousands+ Size: Billions+
1000x faster
![Page 73: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/73.jpg)
Neo Technology, Inc Confidential
Core Industries & Use Cases:
Web / ISV Financial Services
Telecomm-unications
Network & Data Center Management
Master Data Management
Social
Geo
Core Industries & Use Cases: Software
Financial Services
Telecommunications
Health Care & Life Sciences
Web Social,HR & Recruiting
Media & Publishing
Energy, Services, Automotive, Gov’t, Logistics, Education,
Gaming, Other
Network & Data Center Management
MDM / System of Record
Social
Geo
Recommend-ations
Identity & Access Mgmt
Content Management
BI, CRM, Impact Analysis, Fraud Detection, Resource
Optimization, etc.
Accenture
Aviation
Neo4j Adoption SnapshotSelect Commercial Customers* (some NDA)
*Community Users Not Included
![Page 74: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/74.jpg)
Neo Technology, Inc Confidential
Graph Database Deployment
ApplicationOther
Databases
ETL
Graph Database Cluster
Data Storage & Business Rules Execution
Reporting
Graph- Dashboards&Ad-hocAnalysis
Graph Visualization
End User Ad-hoc visual navigation & discovery
Bulk Analytic Infrastructure
(e.g. Graph Compute Engine)
ETL
Graph Mining & Aggregation
Data Scientist
Ad-HocAnalysis
![Page 75: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/75.jpg)
*“Find all direct reports and how many they manage, up to 3 levels down”
(SELECT T.directReportees AS directReportees, sum(T.count) AS count FROM ( SELECT manager.pid AS directReportees, 0 AS count FROM person_reportee manager WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") UNION SELECT manager.pid AS directReportees, count(manager.directly_manages) AS count FROM person_reportee manager WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") GROUP BY directReportees UNION SELECT manager.pid AS directReportees, count(reportee.directly_manages) AS count FROM person_reportee manager JOIN person_reportee reportee ON manager.directly_manages = reportee.pid WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") GROUP BY directReportees UNION SELECT manager.pid AS directReportees, count(L2Reportees.directly_manages) AS count FROM person_reportee manager JOIN person_reportee L1Reportees ON manager.directly_manages = L1Reportees.pid JOIN person_reportee L2Reportees ON L1Reportees.directly_manages = L2Reportees.pid WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") GROUP BY directReportees ) AS T GROUP BY directReportees) UNION (SELECT T.directReportees AS directReportees, sum(T.count) AS count FROM ( SELECT manager.directly_manages AS directReportees, 0 AS count FROM person_reportee manager WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") UNION SELECT reportee.pid AS directReportees, count(reportee.directly_manages) AS count FROM person_reportee manager JOIN person_reportee reportee ON manager.directly_manages = reportee.pid WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") GROUP BY directReportees UNION
(continued from previous page...) SELECT depth1Reportees.pid AS directReportees, count(depth2Reportees.directly_manages) AS count FROM person_reportee manager JOIN person_reportee L1Reportees ON manager.directly_manages = L1Reportees.pid JOIN person_reportee L2Reportees ON L1Reportees.directly_manages = L2Reportees.pid WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") GROUP BY directReportees ) AS T GROUP BY directReportees) UNION (SELECT T.directReportees AS directReportees, sum(T.count) AS count FROM( SELECT reportee.directly_manages AS directReportees, 0 AS count FROM person_reportee manager JOIN person_reportee reportee ON manager.directly_manages = reportee.pid WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") GROUP BY directReportees UNION SELECT L2Reportees.pid AS directReportees, count(L2Reportees.directly_manages) AS count FROM person_reportee manager JOIN person_reportee L1Reportees ON manager.directly_manages = L1Reportees.pid JOIN person_reportee L2Reportees ON L1Reportees.directly_manages = L2Reportees.pid WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") GROUP BY directReportees ) AS T GROUP BY directReportees) UNION (SELECT L2Reportees.directly_manages AS directReportees, 0 AS count FROM person_reportee manager JOIN person_reportee L1Reportees ON manager.directly_manages = L1Reportees.pid JOIN person_reportee L2Reportees ON L1Reportees.directly_manages = L2Reportees.pid WHERE manager.pid = (SELECT id FROM person WHERE name = "fName lName") ) !
Experiencing Query Pain Actual HR Query* (in SQL)
![Page 76: The 5 Graphs of Love](https://reader033.fdocuments.us/reader033/viewer/2022042714/54b6b7a14a79593e4f8b4612/html5/thumbnails/76.jpg)
MATCH (boss)-‐[:MANAGES*0..3]-‐>(sub), (sub)-‐[:MANAGES*1..3]-‐>(report) WHERE boss.name = “John Doe” RETURN sub.name AS Subordinate, count(report) AS Total
Experiencing Query Pain Same Query*, using Cypher
*“Find all direct reports and how many they manage, up to 3 levels down”