Skip to content

Instantly share code, notes, and snippets.

@peterneubauer
Last active December 22, 2015 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peterneubauer/6549962 to your computer and use it in GitHub Desktop.
Save peterneubauer/6549962 to your computer and use it in GitHub Desktop.

Create unique address patterns

CREATE CONSTRAINT ON (city:City) ASSERT city.name IS UNIQUE
CREATE CONSTRAINT ON (p:Person) ASSERT p.name IS UNIQUE

Now, add two addresses in Berlin for the same person by merging the nodes.

MERGE (berlin:City{name:'Berlin'})
MERGE (joe:City{name:'Joe'})
CREATE joe-[:LIVES]->({name:'Address1'})-[:IN]->berlin
CREATE joe-[:LIVES]->({name:'Address2'})-[:IN]->berlin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment