1. A computer-implemented method for generating a computer program that specifies a query for extracting data from a database, the method comprising the steps of: creating an object-oriented diagram describing data structures within the database as object classes and providing a representation of relationships between each of the object classes; interpreting the object-oriented diagram as specifying a subset of all object instances of the object classes that satisfy constraints implied by the relationships in the object-oriented diagram; performing a series of transformations on the object classes within the object-oriented diagram to further specify conditions of the query; producing a revised object-oriented diagram representative of the query; and automatically generating a code for the query from the revised object-oriented diagram.