O'Reilly logo

Neo4j Graph Data Modeling by Mahesh Lal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required