cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Node static types / Schema

I have literally just downloaded and started played around with neo4j an hour ago so I am sorry if this question is basic, I tried to find the answer on google though but couldn't find it.

For my startup product I have a lot of data structured as a DAC graph. I would love to use a database that fits this data, but I would also really like something where I can statically define each type of node. What I mean by that is, I want my int fields to always contain ints and never be empty. And I want an error if I accidentally try to access or assign to an non existing field etc.

Is this possible at all with neo4j?

1 REPLY 1

mark3
Node Link

Hi,

You can certainly configure nodes so that they must contain a particular property. This is done by adding a constraint, e.g.

CREATE CONSTRAINT node_exists ON (p:Person)
ASSERT exists(p.surname)

This will ensure :Person always has a surname, but it will not guarentee its type or that it contains a value.

If you need that level of constraint (and why wouldn't you) then you will have to use triggers which have similar properties to RDBMS triggers. Have a look at:

http://neo4j-contrib.github.io/neo4j-apoc-procedures/3.5/operational/triggers/