Creating your first node and relationship using Cypher
In this recipe, you will learn to create nodes and relationships between them. Nodes can consist of various properties, which describes the nodes. Similarly, properties can also exist on relationships.
Getting ready
To step through this recipe, you will need to run an instance of the Neo4j Server. For the sake of simplicity, we will type the Cypher query from the Neo4j web console, as shown in the following screenshot. However, you can also send queries programmatically, using the language of your choice:
How to do it...
In this recipe, we are creating two airports, J.F Kennedy Airport
, based in New York
, and Austin-Bergstrom International
, based in the city of Austin
. This recipe is as follows:
We are also creating a flight that connects them, which is shown in the following code:
CREATE (JFK:Airport { name:'JF Kennedy Airport', city:'New York' }),(AUS:Airport { name:'Austin-Bergstrom International', city:'Austin' }) CREATE (flight1:Flight...