Data modeling

refactoring

Changing the structure of a graph without changing what it represents, usually to make queries simpler, faster or more logical.

Example

Before, the country a film was made in is a property of the film.

After, it is a node the films share.

cypher
MATCH (m:Movie)
MERGE (c:Country {name: m.country})
MERGE (m)-[:RELEASED_IN]->(c)
REMOVE m.country

Both graphs record the same two facts. In the second, a query reaches Apollo 13 from Toy Story by following two relationships. Before, it had to scan the country property of every film.

Lessons that use this term

The lesson and course links below open in a new tab.

6 lessons use this term. Results are ordered by term density.

Graph Data Modeling Fundamentals4 mentions

  • Refactor Your ModelTesting and Refactoring the Modelyou found a gap, apply whichever refactoring pattern - or combination of patterns - actually fits, using the model editor on the1 mention
  • Refactoring PatternsTesting and Refactoring the ModelA model that answers today's questions might not answer tomorrow's. Refactoring changes a model's shape - without throwing away what already works - so it can answer a question better, or answer one3 mentions

Neo4j Management, Optimization, and Refactoring Workshop11 mentions

  • Why refactor?Graph refactoringthis lesson, you will learn about the importance of graph refactoring and when it's necessary to improve performance and8 mentions
  • Challenge: Refactor the graphGraph refactoringthe challenge above and are looking for an extra challenge, you can try refactoring the graph to calculate and store the total cost of an order by summing the price of the products in the1 mention
  • Normalizing a property to a nodeGraph refactoringparticularly when dealing with large datasets, to create constraints before refactoring your2 mentions

Get started with Graph Data Science2 mentions

All glossary terms