Calculate the number times the email has been forwarded
This query starts at the given email and then matches against all incoming FOR WARD_OF relationships in the tree of forwarded emails to any depth. These relation‐ships are bound to an identifier f. To calculate the number of times the email has been forwarded, we count the number of FORWARD_OF relationships bound to f using Cypher’s count function. In this example, we see the original email has been forwar‐ded twice:
+----------+
1 row
Identifying Nodes and Relationships
4. Translate these entities and relationships into Cypher path expressions.
5. Express the questions we want to ask of our domain as graph patterns using path expressions similar to the ones we used to model the domain.
Avoiding Anti-Patterns
In the general case, don’t encode entities into relationships. Use relationships to con‐vey semantics about how entities are related, and the quality of those relationships.
Identifying Nodes and Relationships | | | 63 |
---|
Summary
Graph databases give software professionals the power to represent a problem domain using a graph, and then persist and query that graph at runtime. We can use graphs to clearly describe a problem domain; graph databases then allow us to store this representation in a way that maintains high affinity between the domain and the data. Further, graph modeling removes the need to normalize and denormalize data using complex data management code.
64 | | |
---|