Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-20-2020 12:46 AM
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?
05-20-2020 06:41 AM
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/
All the sessions of the conference are now available online