O'Reilly logo

Learning Neo4j 3.x - Second Edition by Rik Van Bruggen, Jérôme Baton

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

Property to node

Now, to dissociate a property from a node to a new node, for example, to share a value between nodes, we will see how to dissociate the countries of our towers from the country property to new nodes with the :country label, linked to the towers with a :IN_COUNTRY relation: 

MATCH (t:Tower)MERGE (c:Country {code: t.country})CREATE UNIQUE (t)-[:IN_COUNTRY]->(c)REMOVE t.countryRETURN t,c

You get extra points if you saw that, although a new kind of node is added, no constraint is created.

CREATE UNIQUE makes the relation unique. Run this code several times; there will be only one relation between the nodes.

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