Force relationships from a node label X to a node label Y to have specific properties

telmo_trooper
Thu, 28 Mar 2019 04:10:32 +0000
General

I've made this same question in StackOverflow, but I'm asking here as well to increase the odds of getting some help.

I'm aware that using the "relationship property existence constraint" available in Neo4j Enterprise I can force relationships of a given label to have some properties, for example:

(Relationships of label "LIKED" always have a "day" property)

CREATE CONSTRAINT ON ()-[like:LIKED]-() ASSERT exists(like.day)

But is it possible to force relationships from a node label X to a node label Y to have specific properties? An example of what I would like to do would be:

(Relationships of label "BOUGHT" from/to nodes label "Person" to/from nodes label "Book" always have a "day" property)

CREATE CONSTRAINT ON (p:Person)-[bo:BOUGHT]-(b:Book) ASSERT exists(b.day)

But that isn't considered a valid Cypher command. Is there a way to achieve this effect at a schema level or would I need to implement it in the application layer? Thank you.

3 posts - 3 participants