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

Data Modeling With Graphs

Data Modeling With Graphs

Talk by Ian Robinson, Director Customer Success @NetoTechnology at Data Science London meetup

Data Science London

January 13, 2014
Tweet

More Decks by Data Science London

Other Decks in Technology

Transcript

  1. Modeling  with  RelaDonships   •  Align  with  use  cases  

    – When  querying,  well-­‐named  relaDonships  help   discover  only  what  is  absolutely  necessary   •  No  ‘specializaDon  tax’  
  2. Design  For  Queryability   MATCH (company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill), (company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill) WHERE me.name =

    {name} RETURN colleague.name AS name, count(skill) AS score, collect(skill.name) AS skills ORDER BY score DESC As  an  employee     I  want  to  know  who  in  the  company  I   work  for  has  similar  skills  to  me     So  that  we  can  exchange  knowledge   (:Company)<-[:WORKS_FOR]-(:Person)-[:HAS_SKILL]->(:Skill) Person  WORKS_FOR  Company   Person  HAS_SKILL  Skill ? Which  people,  who  work  for  the  same   company  as  me,  have  similar  skills  to  me?
  3. ApplicaDon/End-­‐User  Goals   As  an  employee     I  want

     to  know  who  in  the  company  I   work  for  has  similar  skills  to  me     So  that  we  can  exchange  knowledge  
  4. IdenDfy  EnDDes  and  ConnecDons   Which  people,  who  work  for

     the  same  company   as  me,  have  similar  skills  to  me?     (:Person)-­‐[:WORKS_FOR]-­‐>(:Company),   (:Person)-­‐[:HAS_SKILL]-­‐>(:Skill)      
  5. Express  QuesDon  as  Graph  Pabern   Which  people,  who  work

     for  the  same  company   as  me,  have  similar  skills  to  me?  
  6. Cypher  Query   Which  people,  who  work  for  the  same

     company   as  me,  have  similar  skills  to  me?   MATCH (company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill), (company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill) WHERE me.name = {name} RETURN colleague.name AS name, count(skill) AS score, collect(skill.name) AS skills ORDER BY score DESC
  7. Graph  Pabern   Which  people,  who  work  for  the  same

     company   as  me,  have  similar  skills  to  me?   MATCH (company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill), (company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill) WHERE me.name = {name} RETURN colleague.name AS name, count(skill) AS score, collect(skill.name) AS skills ORDER BY score DESC
  8. Which  people,  who  work  for  the  same  company   as

     me,  have  similar  skills  to  me?   MATCH (company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill), (company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill) WHERE me.name = {name} RETURN colleague.name AS name, count(skill) AS score, collect(skill.name) AS skills ORDER BY score DESC Anchor  Pabern  in  Graph   Search  nodes  labeled   Person,  matching  on   name  property  
  9. Create  ProjecDon  of  Results   Which  people,  who  work  for

     the  same  company   as  me,  have  similar  skills  to  me?   MATCH (company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill), (company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill) WHERE me.name = {name} RETURN colleague.name AS name, count(skill) AS score, collect(skill.name) AS skills ORDER BY score DESC
  10. Running  the  Query   +-----------------------------------+ | name | score |

    skills | +-----------------------------------+ | "Lucy" | 2 | ["Java","Neo4j"] | | "Bill" | 1 | ["Neo4j"] | +-----------------------------------+ 2 rows