Patent ID: 7797307

Claim:
A query generator comprising a client computer system running query generator software for generating a query which retrieves a desired set of data from a relational database and performs one or more aggregation functions on the set of data, wherein the query generator is adapted to: a) receive user input indicating the desired set of data and the aggregation functions to be performed; b) automatically identify one or more subgraphs for the desired set of data by: i) selecting a source table within the desired set of data; ii) selecting, in a sequential manner, one or more target tables joined to the source table; iii) determining whether the said join is a one-to-one join or a one-to-many join and adding the join between the source and each target table to a list of joins if the said join is a one-to-one join or a one-to-many join when the source table is on the many side; iv) selecting each of the target tables in turn as a new source table; and v) repeating steps (ii) to (iv) recursively, and going to step (c) when there are no more target tables joined to a source table; c) for each join subgraph identified in step (b), automatically generate an inline view which, on execution, performs all of the aggregation functions that refer only to data within that join subgraph; and d) automatically generate an output query comprising the inline views generated in step (c) as arguments of a join, and wherein step (c) determines which of the aggregation functions refer only to data within a join subgraph by: i) generating a list of all possible aggregation levels, including a base aggregation level and all higher levels of aggregation, for the desired set of data; and ii) removing from the list each of the possible aggregation levels that are not contained in the join subgraph.