2
votes

Short question

Does Neo4j support constraints based on a domain-model?

Explanation

In the basic tutorial, it says "Please keep this picture at hand all the time. It details the domain-model for this tutorial." (https://stack.versal.com/api2/assets/fdc05cea-e18b-44ea-8ba9-e119d7a8f872).

But is there any way to check that data stored into the graph respect this domain-model?

For relational databases, we have "create" instructions to build the domain-model and "insert" instructions to store data in compliance with this domain-model.

For graph database in Neo4j, I only found "create" instructions where we can specify a type (that would be part of the domain-model).

What I need to do

I need to create a domain-model that prevent the creation of nodes which are not compliants with the domain-modeln for example:

  • the node type must be in the domain-model
  • a type of association can only link nodes with specific types

Example

With the movie domain-model coming from the tutorial (https://stack.versal.com/api2/assets/fdc05cea-e18b-44ea-8ba9-e119d7a8f872) :

  • A node can only be of type Person or Movie
  • A Movie can't have outgoing edges
  • A DIRECTED or ACTED_IN relationship can't link two Persons
  • ...

Is this possible in Neo4j? Or do I have to create checkers on the model?

1

1 Answers

1
votes

You will have to create checkers of the model or an API that guarantees that only nodes matching the model are added.

Some things that you describe will be added in Neo4j in the future but it has not been decided when.

But I saw a presentation of the http://structr.org application framework today that allows you to model a schema with types, properties and relationships with cardinalities.