Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to constraint edge multiplicity in Neo4j / OrientDB?

I was wondering whether Neo4j and OrientDB provide the possibility of defining constraints in terms of multiplicity for specific edge types?

like image 335
ppareja Avatar asked Oct 09 '14 09:10

ppareja


1 Answers

For OrientDB

You can set multiplicity on out/in collection per label. Example to set maximum 1 edges from Person to Company if the edge's label is "workFor":

ALTER PROPERTY Person.out_workFor NOT NULL
ALTER PROPERTY Person.out_workFor MAX 1

You can also set the minimum with:

ALTER PROPERTY Person.out_workFor MIN 1

In this way with min & max it's mandatory having one and only one relationship to Company.

like image 80
Lvca Avatar answered Sep 28 '22 03:09

Lvca