Ampersand
Ampersand copied to clipboard
First step in adding calculation in Ampersand
In relation to the discussion in #207, I propose to do a small experiment to see how we can add calculations to our expressions and what is needed for that.
Inspired by the SHACL constraint language for RDF (https://www.w3.org/TR/shacl/#core-components), we can define a list of calculations to support, like lessThan
and lessThanOrEqual
.
E.g. for lessThan
we could add the operator <
. We need to define for which types this is supported and the precedence of the operator. The types INTEGER
, FLOAT
, DATE
and DATETIME
.
RELATION r[A*Date]
RELATION s[A*Date]
REPRESENT Date TYPE DATE
RULE I[A] |- r < s
The meaning of the operator <
would be the set of A*A for which the value of tgt of r
is less than the value of tgt of s
, with the restriction that r
and s
are univalent. So r < s
is basically a calculated property for A
.
The generated SQL can be a join of r
and s
(like with r;s
) but instead of the WHERE clause stating r.tgt = s.src
we need r.tgt < s.src
.
What do you think @hanjoosten @sjcjoosten? Can we add this one to see how it goes?