A semantic query may refer to a logical rule, where the rule is defined in terms of constituent expressions. In order to execute the semantic query efficiently, occurrences of the rule may be expanded by replacing the rule with its constituent expressions. Expansion may be performed repeatedly, until only grounded expressions remain. Expressions are grounded when they refer to tables or views that are represented in an underlying database. Once the rule has been reduced to grounded expressions, the semantic query processor may formulate a relational query in terms of the grounded expressions. If the relational query takes into account the various grounded expressions to which the rule reduces, then the portion of the semantic query that refers to the rule may be processed without an excessive number of round trips to the relational database.