Refactoring and Evolving Your Graph Model
Learn how to evolve a Neo4j graph model safely over time using refactoring patterns and reshaping queries.
Models Are Never Final
As applications grow, your graph model will change. New questions demand new structure. Refactoring lets you reshape the graph without losing data.
Property to Node
A common refactor: a property shared by many nodes (like a city name) becomes its own node so it can hold relationships.
MATCH (p:Person)
WHERE p.city IS NOT NULL
MERGE (c:City {name: p.city})
MERGE (p)-[:LIVES_IN]->(c)
REMOVE p.city;All lessons in this course
- Principles of Graph Data Modeling
- Designing Your First Graph Model
- Schema Constraints and Indexes
- Refactoring and Evolving Your Graph Model