A method and apparatus is provided for generating structured query language instructions for communication to a database. In response to receipt of user-supplied input dimensions, an output table is automatically selected that represents the user's query of the relational database. The system automatically identifies and generates the links between data in predefined data tables within the database and the automatically selected output table. From the output table and data links, structured query language instructions are automatically generated. A technique is included to select the minimum number of tables reflective of the input dimensions. Each link between the input data tables and the output table is checked bi-directionally to ensure the integrity of the table selected.