Redisgraph: Unique constraint on an attribute

Created on 16 May 2019  路  10Comments  路  Source: RedisGraph/RedisGraph

I can't use MERGE in my use case, is there any way on the road map to add a Unique constraint?

In my case I'm creating a lot of duplicates if something goes wrong, and body of the nodes contain a creation date, so MERGE won't work

enhancement no-issue-activity

Most helpful comment

@flpgrz We have not introduced support for any constraints as yet! It's a feature request we've heard from a few users, but introducing schema impositions would be a significant change for RedisGraph, so I'm not sure where it will fall upon our roadmap currently.

All 10 comments

Hi @WitchsCat,
We haven't gave much thought to unique constraint, let me consult with the team and we'll update here.

I am also facing the same issue, lots of duplicate records(node). In my case, data integrity is very important the same user gets created multiple time.

@amitsharma8891
Can't you use Merge to avoid duplicates?

Thanks for your response, earlier I tried using but the problem with Merge is if a small change in property instead of updating the same node with the same user_id it created a new Node.

user = Node(label='User', properties={'user_id':'someid','name': 'helloo'}) user = Node(label='User', properties={'user_id':'someid','name': 'hell'}) # -- This creates new node instead updating the 'someid' node

This causes a major issue and couldn't continue

Thanks

I see your point, currently the only solution I can think of is finding out if a User node with a given user_id already exists (create an index over User:user_id) if it does, then you can update/add properties to it, otherwise you would have to create it.

Thanks for your response. Do you have any roadmap to introduce unique constraints?

Come to think of it, you might be able to use both MERGE and SET,
MERGE on user_id and SET name.

Stale issue message

_RedisGraph v2.0.15_

Any news concerning the support of UNIQUE CONSTRAINTs?

I was try to create this constraint, but it fails:
CREATE CONSTRAINT node_id ON (n:Node) ASSERT n.id IS UNIQUE

This is normally working on Neo4J - so I was wondering if maybe you support a different syntax, or if the feature is simply not available at the moment.
Thanks.

@flpgrz We have not introduced support for any constraints as yet! It's a feature request we've heard from a few users, but introducing schema impositions would be a significant change for RedisGraph, so I'm not sure where it will fall upon our roadmap currently.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

K-Jo picture K-Jo  路  9Comments

esokullu picture esokullu  路  3Comments

Talha-B picture Talha-B  路  5Comments

mdecuir picture mdecuir  路  12Comments

abevoelker picture abevoelker  路  5Comments