Database Reference
In-Depth Information
Figure 2.14. Two underground stations, with connections on two different lines
In order to know what lines Euston station is on, however, you now have to find out what
connections it has to other stations. Fortunately, you can do this easily enough with a
Cypher query:
This will find all of the connections between Euston and any other station, and return the
distinct line property values of all of those connections.
Both of these two ways of modeling the tube system are capable of containing exactly the
sameinformation.Itwouldbepossibletowritequeriestotransformagraphmodeledinthe
first way into a graph modeled in the second, and back again, without losing any detail. So
how do you choose which way is best? The answer mainly depends on how you're going
to populate your database, and how you're going to query it.
If, as in the first model, you have to create and manage explicit nodes and relationships to
represent the existence of train lines and the fact that certain stations are on certain lines,
then the database may be more unwieldy, and harder to visualize clearly, than one in which
the only nodes are those representing stations, and the only relationships are those repres-
enting connections between stations. Running a query to find all of the stations that are on
aparticularlinewouldbeveryquick,astheNeo4jdatabaseenginewillonlyhavetofollow
the relationships from a single node to all of its immediately connected nodes:
 
Search WWH ::




Custom Search