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 ...

Get Neo4j Graph Data Modeling now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.