10. 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 an expression in a query language, the expression having a query language construct representing an algebraic data type, wherein the expression specifies two or more alternative subtypes; generating, for each of the alternative subtypes, a respective domain relation having domain tuples that satisfy a definition of the alternative subtype within the expression; generating a respective domain id relation for each of the domain relations of the alternative subtypes, wherein the domain id relation for a corresponding domain relation of an alternative subtype has domain id tuples that each assign a respective unique domain identifier to each of the domain tuples belonging to the corresponding domain relation of the alternative subtype; generating a union relation for the algebraic data type, wherein the union relation assigns a respective branch identifier to each of the two or more alternative subtypes and, for each of the domain id relations, defines union tuples that each have i) a respective unique domain identifier of a domain id tuple of the corresponding domain id relation and ii) a branch identifier for the alternative subtype to which the domain id relation belongs; assigning unique union identifiers to each of the union tuples belonging to the union relation; generating a respective injector relation for each of the alternative subtypes, wherein each injector relation for an alternative subtype has injector tuples, each injector tuple having i) a first element from a particular domain tuple of the domain relation for the alternative subtype and ii) a union identifier assigned to a union tuple having (a) a unique domain identifier of the particular domain tuple according to the domain id relation for the alternative subtype and (b) a branch identifier for the alternative subtype; receiving a query referencing a variable having the algebraic data type, the algebraic data type having the two or more alternative subtypes; computing query results for the query including identifying one or more injector tuples that satisfy the query, each injector tuple satisfying the query belonging to one of the injector relations generated for the two or more alternative subtypes of the algebraic data type referenced by the query; and providing the computed query results in response to receiving the query.
10. 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 an expression in a query language, the expression having a query language construct representing an algebraic data type, wherein the expression specifies two or more alternative subtypes; generating, for each of the alternative subtypes, a respective domain relation having domain tuples that satisfy a definition of the alternative subtype within the expression; generating a respective domain id relation for each of the domain relations of the alternative subtypes, wherein the domain id relation for a corresponding domain relation of an alternative subtype has domain id tuples that each assign a respective unique domain identifier to each of the domain tuples belonging to the corresponding domain relation of the alternative subtype; generating a union relation for the algebraic data type, wherein the union relation assigns a respective branch identifier to each of the two or more alternative subtypes and, for each of the domain id relations, defines union tuples that each have i) a respective unique domain identifier of a domain id tuple of the corresponding domain id relation and ii) a branch identifier for the alternative subtype to which the domain id relation belongs; assigning unique union identifiers to each of the union tuples belonging to the union relation; generating a respective injector relation for each of the alternative subtypes, wherein each injector relation for an alternative subtype has injector tuples, each injector tuple having i) a first element from a particular domain tuple of the domain relation for the alternative subtype and ii) a union identifier assigned to a union tuple having (a) a unique domain identifier of the particular domain tuple according to the domain id relation for the alternative subtype and (b) a branch identifier for the alternative subtype; receiving a query referencing a variable having the algebraic data type, the algebraic data type having the two or more alternative subtypes; computing query results for the query including identifying one or more injector tuples that satisfy the query, each injector tuple satisfying the query belonging to one of the injector relations generated for the two or more alternative subtypes of the algebraic data type referenced by the query; and providing the computed query results in response to receiving the query. 18. The system of claim 10 , wherein generating a domain id relation for an alternative subtype comprises assigning the same unique domain identifier to all domain tuples having identical elements.