39. The system of claim 33 , 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.
33. A system comprising: one or more computers and one or more storage devices storing instructions that are operable, when executed by the one or more computers, to 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 )|}}.