23. The one or more non-transitory computer-readable storage media of claim 17 , wherein the aggregation function agg has multiple input types, and the relation t is a relation from the range of s to the multiple input types of the aggregation function agg.
17. One or more non-transitory computer-readable storage media encoded with instructions that, when executed by one or more computers, cause the one or more computers to perform operations comprising: receiving input specifying, explicitly or implicitly, (i) an aggregation function agg having an input type and an output type, a relation s that has a domain and a range, wherein s represents one or more entities to be aggregated over, and a relation t that is a relation from the range of s to the input type of the aggregation function agg, and (ii) a recursive relation definition, wherein an aggregation construct agg* is within a recursive term of the recursive relation definition; and evaluating the recursive relation definition, including evaluating the aggregation construct agg* to calculate a relation between the domain of s and the output type of the aggregation function agg according to 
 agg*( s,t )={( m ,agg( n ))|∃ d :( m,d )ε s,nεΠ{|t ( y )| yεs ( m )|}}.