-
Notifications
You must be signed in to change notification settings - Fork 45
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
Make annotated constraints to apply to subtypes #291
Comments
It is worth considering: would all annotations be inherited in the same way, including planned ones? I think we want to avoid having different inheritance behaviour for different annotations as that manifests as an invisible rule that users will have to learn the hard way unless they read the enitre docs. A user, having learned how one annotation is inherited, would likely assume that all other annotations are inherited in the same way. Even if we signpost any disparity well enough that it can't be missed, it still represents an additional hurdle when learning the language. |
As a quick suggestion. Being able to declare
|
On the attribute or the attribute type? |
Attribute type. In the same way the regex and the value type is global: define
email sub attribute,
value string,
regex "^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$",
unique; Then, for the current behaviour ( This would work also for cardinality constraints, enabling typeDB users to define them globally for an attribute, or scoped. A quick classification I have in mind:
Where chained means being able to make it more strict on each sub-definition. ExamplesFormat A (two ways to add restrictions) define
using-auth-providers sub attribute,
value string,
regex "^(google|facebook|github|other_auth_provider)$";
user sub entity,
owns using-auth-providers @card(*);
superUser sub user , #users with that need to have configured at least two auth providers and only using top providers
owns using-auth-providers @card(2,*) @regex("^(google|facebook|github)$"); Format B (restrictions only on attributeType definition) define
using-auth-providers sub attribute,
value string,
regex "^(google|facebook|github|other_auth_provider)$",
cardinality *;
super-using-auth-providers sub attribute,
value string,
regex "^(google|facebook|github)$",
cardinality (2,*);
user sub entity;
normalUser sub user,
owns using-auth-providers;
superUser sub user,
owns super-using-auth-providers; I'm probably not thinking on other alternatives and edge cases, but the key thing is to provide a way to do both global and scoped constraints somehow |
Problem to Solve
To share the Unique constraint between multiple types.
E.g., all cars have a unique ID (License plate number), including subtypes of
car
, likesedan
andhatchback
.See the generic schema example below:
Current Workaround
The code above will work, but the constraint of uniqueness for the
id
is applied separately for every subtype.Proposed Solution
The subtypes will share the pull of unique constrained values of
id
.The following insert query should return an error:
Additional Information
The text was updated successfully, but these errors were encountered: