/ relational operations - sa 2005.6.15. modified 2023.6.29 \l show table:{[f;n;m]@[_n;f;{:[@y;n _draw y;y n _draw#y]};m]} select:{[t;i]@[t;_n;@[;i]]} project:{[t;f;g]@[_n;f;:;t g]} group:{[t;k;f;o]@[_n;k,name'[f;o];:;(+?+t k),o@''t[f;=+t k]]} name:{[f;o]`$($o),"_",$f} avg:{(+/x)%#x} sum:+/ count:#: list:(::) order:where:{[t;f;o]{x y z x}/[_n;o;t f]} desc:>: asc:<: link:{[t;u;k;l]@[t;!u;:;u[;(+u@(),l)?/:+t@(),k]]} insert:{[t;d]@[t;_n;,;d]} update:{[t;f;i;d].[t;(f;i);:;d]} delete:{[t;i]@[t;_n;_di[;i]]} t:table[`f`g`h`i`j;10;(`a`b`c`d`e;7;0;0;0)] t:insert[t;(`a`b`b`a;3 5 6 2;.1*!4;.2*!4;.3*!4)] u:select[t;where[t;`f`g;({&x _lin`a`b};&5=)]] v:select[u;order[u;`g`f;`desc`asc]] w:group[t;`f`g;`h`h`h`i;`count`sum`avg`sum] x:select[w;order[w;`g`f;`desc`asc]] show'(t;u;v;w;x); d[`f`g]:(`a`a`b`a`b`c`c`c`a`a;10_draw 100) k[`f`h`i]:(`a`b`c;100 200 300;1.1 2.2 3.3) show d show k show link[d;k;`f;`f] \ table[f;n;m] returns a table of cardinality n with cols f whose values are drawn from m insert[t;d] returns t with d appended update[t;f;i;d] returns t with cols f updated at i with d delete[t;i] returns t with rows i deleted select[t;i] returns t restricted to rows i project[t;f;g] returns t with cols g of t projected to f group[t;k;f;o] returns t with keys k and aggregations o[1]f[1] ... o[n]f[n] where[t;f;o] returns indices of rows where o[1]f[1] and ... and o[n]f[n] order[t;f;o] returns indices of rows sorted by o[1]f[1] within ... within o[n]f[n] link[t;u;k;l] returns the join of the data table t with the key table u