typedb icon indicating copy to clipboard operation
typedb copied to clipboard

TypeDB 3.0: Allow abstract attribute hierarchies without value types

Open flyingsilverfin opened this issue 1 year ago • 0 comments

Problem to Solve

There is an inconsistency in the attribute type definition: we allow the root Attribute type to be valuetype-less, and abstract. All user attribute types derive from this root type. However, they must always explicitly declare a value type, even if abstract.

In some cases, we want to be able to have distinct value types under a single user-defined Type. Consider id, the common case, where some IDs are strings, some are longs, and some are timestamps.

Current Workaround

Make different user-defined types per value type, and for query them separately.

Proposed Solution

We should allow extending the example set by the root Attribute type:

define
id sub attribute, abstract; # no value type required
email sub id, value string;
timestamp sub id, value datetime;
...

We will arbitrarily depth attribute hierarchies as long as they are all abstract and do not contain a value type. All concrete attribute types must have a value type, and as soon as a value type is introduced, the all subtypes must follow the supertype's value type from there on.

flyingsilverfin avatar Mar 17 '23 09:03 flyingsilverfin