Database Reference
In-Depth Information
This will run very quickly if you have an index on the name property of Line nodes, as
the Neo4j query engine will be able to use that index to pick out its starting node.
The corresponding query against the second model will require a much more complex tra-
versal of the graph in order to get its results.
In this case, the engine must consider every connected relationship between a pair of
Station nodes, gather up all the nodes where the relationship has the required line
property,andreturnalltheunique Station names.Ifthisisaqueryyou'relikelytowant
to run often, it may be worth considering surfacing the information it recovers by creating
explicit nodes and relationships that represent that information.
What this example shows is that sometimes it makes sense to have some of the entities in
your domain model remain implicit in the graph, rather than represent them explicitly with
dedicatednodes.Conversely,it'ssometimesworthsurfacingimplicitinformationandmak-
ing it explicit so that it can be found more quickly by Neo4j's query engine.
2.3.2. Band members example
Our second example concerns modeling data to deal with information that changes over
time, so that you can separate invariant aspects of the data from varying aspects. Suppose
youwanttokeeptrackofwhichmusiciansplayedwhichinstrumentsonrecordingsbyvari-
ous rock bands. A simple model might look like figure 2.15 .
Search WWH ::




Custom Search