Patent ID: 8732138

Claim:
A non-transitory computer-readable medium storing program code to determine statistics for a field of a database table, the program code comprising: code to determine that the field of the table is associated with a field of a check table; code to determine that a cardinality indicative of a logical relationship between the field of the table and the field of the check table is 1:0 . . . n, n =0,1,2 . . . , or 1:1 . . . n, n =1,2,3 . . . ; code to if the cardinality is 1:0 . . . n, n =0,1,2 . . . , read rows of the table to identify a number of distinct values of the field in the table until the first of: 1) each row of the table has been read; and 2) the identified number is equal to a number of distinct values of the field in the check table; and code to, if the cardinality is 1:1 . . . n, n =1,2,3 . . . , determine that the number of distinct values of the field in the table is equal to the number of distinct values of the field in the check table without reading a row of the table.