Adding flights to Neo4j

Since we have identified flights as entities, we will create them as nodes. To begin with, we should create a uniqueness constraint on the property code for the label :Flight as shown:

neo4j-sh (?)$ CREATE CONSTRAINT ON (flight:Flight) ASSERT flight.code IS UNIQUE;

The output is as follows:

+-------------------+
| No data returned. |
+-------------------+
Constraints added: 1

We can create a flight with its information as a standalone entity:

neo4j-sh (?)$ CREATE (flight:Flight {code:"AA9", carrier:"American Airlines", duration:314, source_airport_code:"JFK", departure:1300, destination_airport_code:"LAX", arrival:114}) RETURN flight.code as flight_code, flight.carrier as carrier, flight.source_airport_code as from, flight.destination_airport_code ...

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.