The answer to most general purpose graph modelling questions is "it depends". This talk demonstrates the pitfalls of modelling without knowing use cases- it shows how two sets of people can produce two different models for the same set of data elements, and how use cases should guide the model.
About the speaker:
Luanne Misquitta is VP of Engineering at GraphAware, and has been working with Neo4j for 10+ years. She was a core committer to Neo4j OGM and SDN 4, has spoken at GraphConnect in both Europe and the US.
NODES 2019 - Neo4j Online Developer Expo & Summit - 10th October 2019
9. Don’t be afraid!
GraphAware®
‣ Graph modelling is an extremely useful exercise
‣ Validate your understanding of the problem on a whiteboard
‣ The way you naturally represent your domain on the whiteboard is generally
your graph model
‣ No normalisation rules required- all stakeholders can participate
‣ Expose gaps in thinking, missing data early
‣ This modelling is beneficial even if you’re not using a graph database
‣ But if you draw it as a graph, and think of it as a graph, you probably need a
graph database
15. What is the question?
GraphAware®
‣ The use case or the question you’re asking of the graph will determine
the most suitable graph model to
‣ Answer the question
‣ Perform efficient queries
‣ Keep things simple- model just enough, but no more
16. ‣ As a movie fan, I want to find a movie, and see actors and their roles
Use case #1
GraphAware®
17. ‣ As a movie fan, I want to find a movie, and see actors and their roles
Use case #1
GraphAware®
Person
name
Movie
title
genre
ACTED_IN
DIRECTED
roles:[“role1”,”role2”]
18. ‣ As a movie fan, I want to find movies in genres similar to my favourites
Use case #2
GraphAware®
19. ‣ As a movie fan, I want to find movies in genres similar to my favourites
Use case #2
GraphAware®
Person
name
Movie
title
ACTED_IN
DIRECTED
roles:[“role1”,”role2”]
Genre
name
HAS_GENRE
Movie
title
Genre
name
ACTED_IN
HAS_GENRE
SIMILAR_TO
20. ‣ As a movie fan, I want to find actors who played the role of Neo and the
awards they won for this role
Use case #3
GraphAware®
21. ‣ As a movie fan, I want to find actors who played the role of Neo and the
awards they won for this role
Use case #3
GraphAware®
Person
name
Movie
title
DIRECTED
Genre
name
HAS_GENRE
Movie
title
Genre
name
ACTED_IN
HAS_GENRE
SIMILAR_TO
Role
name
<hyperedge>
Award
name
PLAYED_ROLE
AWARD_ROLE
ROLE
ROLE_IN_MOVIEYear
22. Summary
GraphAware®
‣ Know thy use case
‣ Keep it simple and intuitive
‣ Consider
‣ the shape and size of your data
‣ the density of relationships
‣ selectivity
‣ read vs write trade-offs
‣ Measure performance but…
‣ Do not prematurely optimise- graph model refactoring is easy!
23. Hunger Games
GraphAware®
1. Easy: To be able to model your graph well, you should know
A. Your use case
B. The weather
C. A list of hair-metal bands
2. Medium: Should I model this fact as a property of a node, or a node?
A. Property of a node
B. A node
C. It depends
3. Hard: Sometimes you need an edge that relates more than 2 nodes. What do
you do?
A. Use a relationship between two nodes, store the context as properties
B. Use a hyper edge
C. Model with multiple nodes but identify they belong together with a groupID
Answer at: r.neo4j.com/hunger-games