Query Language

A query language is a language for asking a database questions: retrieving rows that match some criteria, combining data from several tables, and computing summaries such as counts and totals. The defining trait of the most influential query languages is that they are declarative. The user describes what data is wanted, and the database system decides how to find it.

This idea is visible in the original SEQUEL paper from IBM, which introduced the language that became SQL. The paper presents queries as “keyword English templates which reflect how people use tables to obtain information,” and stresses that the language reaches the expressive power of first-order predicate calculus without forcing the user to write quantifiers or bound variables. The user states a condition; the system handles the mechanics of scanning and matching data.

Separating what from how is powerful because it lets the database engine choose among many possible execution strategies, picking indexes and join orders to run a query efficiently. The same written query can run unchanged as data grows or as the system gains better internal methods, because only the engine’s strategy needs to change, not the query itself.

SQL is the dominant example of a query language, but the concept is broader and older. Query languages exist for many data models beyond relational tables, including languages for XML and for graph data, yet they share the same core promise: let people express the result they want and let the system find the path to it.