Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Unique Constraint in DQL #8408

Closed
jdgamble555 opened this issue Nov 2, 2022 · 2 comments
Closed

[FEATURE]: Unique Constraint in DQL #8408

jdgamble555 opened this issue Nov 2, 2022 · 2 comments
Labels
area/querylang Issues related to the query language specification and implementation. community Issue or PR created by the community. kind/feature Something completely new we should consider.

Comments

@jdgamble555
Copy link

jdgamble555 commented Nov 2, 2022

Have you tried Dgraph before this proposal? and did not find anything similar?

No response

What you wanted to do.

From the DQL level up, there should be a way to force uniqueness. For backwards compatibility this should be easy. Adding this to a node that already has duplicate values would not be allowed.

This simplest way todo this would be to have a @unique directive in the dql schema:

type Film {
  name @unique 
  release_date
  revenue
  running_time
  starring
  director
}

or with a composite index:

type Film @unique(name, release_date)  {
  name
  release_date
  revenue
  running_time
  starring
  director
}

This should also be possible on a 'facet', but there would need to be a way to declare facet types in dql. Perhaps:

facet Friend {
  close @unique
  ...

and for composite:

facet Friend @unique(close, date) {
  close
  date
}

Note: In GraphQL, the unique directive would need the "field" input to be not break the GraphQL spec, here we can simplify it with just an array inside ().

What you actually did.

You can create this in GraphQL, but it is not enforced once added, and DQL is certainly not enforced. Composite indexes are also currently impossible.

Why wasn't it great, with examples.

We need better data integrity.

Additional information.

It should be 100% impossible to add any kind of duplicate data once this unique directive is activated.

Unique constraints should be nullable by default, but could be not null with the @NotNull directive.

This is how @akon-dey wants to implement this. First in DQL, then GraphQL.

Related to:

@jdgamble555 jdgamble555 added the kind/feature Something completely new we should consider. label Nov 2, 2022
@rderbier rderbier moved this to 📋 Backlog in Feature Requests - PM RoadMap Nov 16, 2022
@rderbier rderbier moved this from 📋 Backlog to 🔖 ASAP in Feature Requests - PM RoadMap Nov 18, 2022
@rderbier rderbier added community Issue or PR created by the community. area/querylang Issues related to the query language specification and implementation. labels Dec 15, 2022
@rderbier rderbier moved this from NEXT to NOW in Feature Requests - PM RoadMap Jan 4, 2023
@rderbier rderbier moved this from NOW to NEXT in Feature Requests - PM RoadMap Feb 21, 2023
@rderbier rderbier moved this from NEXT to NOW in Feature Requests - PM RoadMap Feb 21, 2023
@rderbier
Copy link
Member

partially addressed in JIRA https://dgraph.atlassian.net/browse/DGRAPHCORE-206 sprint 5

@rderbier
Copy link
Member

rderbier commented Jun 9, 2023

replaced by #8865 which is linked to the JIRA covering this new feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/querylang Issues related to the query language specification and implementation. community Issue or PR created by the community. kind/feature Something completely new we should consider.
Development

No branches or pull requests

2 participants