1. A computer readable storage medium containing instructions of a program which, when executed by a processor, performs operations for retrieving data comprising: in response to receiving a query, determining whether the query satisfies at least one of a plurality of conditional constraints, wherein each constraint is programmatically generated by execution of a constraint generation routine that performs a constraint generation operation, comprising: issuing a first query to retrieve distinct values for a first field; receiving results for the first query, the results comprising the distinct values for the first field; for each of the distinct values for the first field, issuing a second query configured to retrieve, for a second field, a result set that satisfies a first condition comprising the first field related to the distinct value by an operator; determining whether a correlation exists between (i) the respective distinct value of the first field and (ii) a respective result set value of the second field; and if a correlation exists, defining a conditional constraint for the first field based on the correlation, wherein the conditional constraint specifies the addition of a second condition to a query if the query includes the respective first condition, wherein the second condition includes the second field related to the respective result set value by an operator; and for each conditional constraint satisfied, adding the respective second condition corresponding to the satisfied conditional constraint to the received query to produce a modified query.