Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Create Nodes and Relationships in Neo4J with Cypher

    Matt RossMatt Ross

    There are different types of data in Neo4J: Nodes and Relationships. We will cover the ways to create each type of data: creating nodes with properties, creating nodes with relationships, and creating constraints on nodes and relationships.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Instructor: The most basic CREATE command has the following structure. CREATE followed by a variable name and a label in parentheses, separated by a colon. We can also assign multiple labels to a node.

    This will create a node with the label "Character" in our graph. If we want to do something a little more useful, we can set key value pairs when creating the node. We can also set these properties by using the SET clause and referencing the variable Leia.

    The CREATE statement can also be used to create data other than nodes. We can, for instance, create nodes with relationships between them and optionally, create properties on those relationships.

    We can also create a constraint on our graph, asserting that only one node with a certain property value can exist. We can do similar things with relationships. Here, we will say that a particular property must exist on all relationships of a given type. Similarly, we can drop any constraints we may have created.