1. A method comprising: receiving a first query in an online analytic processor (OLAP) executing on one or more computers; generating a model, the model specifying a graph defining a plurality of nodes and a plurality of tiers, each node corresponding to a different operation on data; generating a second query based on the model, the second query including a plurality of layered subqueries each corresponding to one of the nodes in the graph for specifying the different operations on the data; receiving the second query in a relational engine coupled to a datastore, wherein the relational engine executes the second query, and in accordance therewith, retrieves data, wherein the plurality of nodes includes a root node on a first tier, a plurality of second tier nodes on a second tier, and one or more higher tier nodes on a plurality of tiers above the first tier and the second tier, wherein the root node has a corresponding first subquery to operate on raw data in the database to retrieve first data, wherein the first data comprises all the data required to answer the first query, wherein the plurality of second tier nodes are coupled to the root node in the graph and each have corresponding subqueries that perform different operations on the first data, wherein at least one of the second tier nodes is coupled to the one or more higher tier nodes, wherein each higher tier node has a corresponding subquery for operating on data generated by the subquery of the at least one second tier node; and generating an answer to the first query by operating the plurality of layered subqueries on the first data only, according to the graph.