Teodora Gorgieva
Teodora Gorgieva

Reputation: 13

How to create constraint on multiple properties in Neo4j

i want to create an unique constraint involving multiple properties but i keep getting the same error executing: CREATE CONSTRAINT UQ_TimeGender ON (tg:TimeGender) ASSERT (tg.date, tg.time, tg.sex) is NODE KEY;

Neo.DatabaseError.Schema.ConstraintCreationFailed Unable to create CONSTRAINT ON ( timegender:TimeGender ) ASSERT exists(timegender.date, timegender.time, timegender.sex):Node(7) with label TimeGender must have the properties (date, time, sex)

When i check TimeGender node it has the properties date, time and sex.

Upvotes: 1

Views: 573

Answers (1)

cybersam
cybersam

Reputation: 67009

Are you sure all TimeGender nodes have all 3 properties?

You can execute this query will to check. It will return any TimeGender nodes that are missing some of those properties.

MATCH (tg:TimeGender)
WHERE tg.date IS NULL OR tg.time IS NULL OR tg.sex IS NULL
RETURN tg

Upvotes: 1

Related Questions