Discussion Forum

General Purpose entity?

The problem I face is that the input is in the form of:

(entity, atribute 1 value , atribute 2 value , …, atribute n value )

The number n is unknown and the type of the attributes are defined by other entries that are provided in the same data format.
How do I define this in the schema? Is there a way for the database to infer roles, relations etc?

You’ll have to define all your types ahead of time (similarly to how you have to declare all your SQL columns beforehand).

However you can insert as many of the same attribute as you want:

define person sub entity, owns email; email sub attribute, value string;


insert $x isa person, has email "abc@gmail.com", has email "def@gmail.com", has email "billy@outlook.com"...

What I meant is how do I define a completely abstract entity with abstract attributes, roles, relationships etc?

Basically since the input can define previous inputs is it possible to define a schema that will take the input and start organizing them until they are grounded somewhere.
Would something like this work?


input sub entity, abstract,
owns name,
name sub attribute, value string,
plays role:rolelabel,
relates data;

data sub input, abstract,
relates integralnumber,
relates integralnumber,
relates decimalnumber,
relates textdata,
relates booleandata,
relates datetime,
integralnumber sub attribute, value long,
decimalnumber sub attribute, value double,
textdata sub attribute, value string,
booleandata sub attribute, value boolean;

rolelabel sub

this is basically what you’ve done - you just define an abstract entity:

my-entity sub entity, abstract;

and then define abstract relations, abstract attributes, etc:

my-entity sub entitry, abstract,
  plays my-relation:my-role,
  owns my-string-attribute;

my-relation sub relation, abstract,
  relates my-role;

my-string-attribute sub attribute, value string, abstract;

nothing wrong with that!