Systems and methods for query generation based on a logical data model are described. For example, methods may include accessing a first join graph representing tables in a database; receiving a first query that references data in two or more of the tables of the database; selecting a connected subgraph of the first join graph that includes the two or more tables referenced in the first query; generating multiple leaf queries that reference respective subject tables that are each a root table of the connected subgraph or a table including a measure referenced in the first query; generating a query graph that specifies joining of results from queries based on the multiple leaf queries to obtain a transformed query result; and invoking a transformed query on the database that is based on the query graph and the queries based on the multiple leaf queries to obtain the transformed query result.