Nodes
During this part of the tutorial we will build a small database that contains the nodes containing the actual persons and countries and learn how we can achieve basic CRUD operations with those nodes.
Creating Nodes
Now, after we have added some constrains and indexes, it's time to add some nodes of persons and countries.
Note
Do note that we need to run these commands one by one in the web interface, as the variable for for each person is named as p and it would clash as that variable would have been previously already created.
Adding Persons
CREATE (p: Person { userId: 1 } ) SET p.email = "alley@gmail.com", p.firstname = "Alex", p.lastname = "Jones", p.city = "Helsinki", p.age = 25
CREATE (p: Person { userId: 2 } ) SET p.email = "v@gmail.com", p.firstname = "Veronica", p.lastname = "Paddington", p.city = "Turku", p.age = 52
CREATE (p: Person { userId: 3 } ) SET p.email = "veski@gmail.com", p.firstname = "Veronica", p.lastname = "Skier", p.city = "Turku", p.age = 52
CREATE (p: Person { userId: 4 } ) SET p.email = "tom@gmail.com", p.firstname = "Tom", p.lastname = "Jones", p.city = "Pori", p.age = 18
CREATE (p: Person { userId: 5 } ) SET p.email = "britpop@gmail.com", p.firstname = "Brittany", p.lastname = "Pop", p.city = "Nokia", p.age = 28
This created us 5 nodes for persons that contain the label Person and each of the persons have their own properties.
Adding Countries
Let's also create couple countries:
This created us 2 nodes for countries that contain the label Country and each country have their own name property set.
Adding Hobbies
Great! And as a last thing, let's also add couple hobbies that we could later on associate with the persons:
Note
Note that, as specified above, we do not need to add index or constraints in order to create new labels. The new label is always created on-the-fly whenever the first node, relationship or constraint is created with the specified label and the label did not exist yet.