Extracting airport information from flights
There are multiple steps involved in making the successful transition from airports being properties of flights to airports being an entity connected to the city they are located in.
To start with, let's create a constraint so that an airport can be uniquely identified by its code. The query is as follows:
neo4j-sh (?)$ CREATE CONSTRAINT ON (airport:Airport) ASSERT airport.code IS UNIQUE;
The output of the preceding query is as follows:
+-------------------+ | No data returned. | +-------------------+ Constraints added: 1
Breaking airports out as a node
The next step is to break out the source_airport_code
and destination_airport_code
properties into nodes. After this change, the :HAS_FLIGHT and :FLYING_TO relationships will connect :Flight and :Airport rather than :Flight and :City, as shown:
In Figure 5.3, the relationships depicted with the dotted line exist currently. Relationships shown with...