The invention introduces a method and system to automatically derive the
relationships between query subjects and query items within query
subjects so that problems such as those that result in double courting of
information are avoided. It provides for creating a report by first
defining a model based on an existing database comprising two or more
query subjects, each query subject comprising at least one fact query
item and one primary key, then generating a hierarchy of sets and subsets
of key query items within the model. Next a further fact is introduced
into one of the query subjects. The expression is decomposed into
sub-queries to prevent double counting of data in ambiguously defined
situations. This is achieved using the introduced fact to determine that
such decomposition is required. Finally, the data is accessed using the
sub-queries, and a report is produced.