Overview

Query by Example (commonly abbreviated QBE) is an approach for creating database queries using a visual, form-based interface rather than writing text-based statements. It presents the user with a screen that looks like a table or schema and lets them indicate the desired selection by filling in fields, marking columns, or clicking on headers. The actions performed in the visual editor are converted behind the scenes into a conventional query language such as SQL so that the database engine can execute them.

How QBE works

Typical QBE tools display a representation of tables and columns; users enter example values, constraints, or placeholders to express what they want returned. A generating component or parser translates the completed form into an executable statement. Because the user manipulates a visible schema instead of memorizing syntax, QBE makes common tasks—selecting columns, filtering rows, and expressing simple joins—more accessible to occasional users.

History and context

QBE was developed in the 1970s at IBM as part of research into user-friendly access to data stored in relational databases. Its development ran roughly in parallel with SQL and other early query systems. The design goal was pragmatic: let people who do not write queries regularly retrieve and manipulate data without needing to learn a full textual language. Over time, the ideas behind QBE influenced many graphical query designers and form-based database tools.

Characteristics and typical features

  • Visual schema presentation: displays tables and columns in a grid or canvas so users can point-and-click rather than type.
  • Fill-in templates: entering example values indicates search constraints (for instance, putting "Smith" under a name column to find records matching that value).
  • Automatic translation: the tool generates an equivalent SQL or other query language statement behind the scenes.
  • Support for joins and aggregation: many QBE interfaces provide ways to express joins and simple aggregates, though very complex queries may still require manual SQL.
  • Target audience: aimed at occasional or non-expert users who need ad hoc access to data.

Uses, variations and examples

Elements of QBE appear in desktop database tools, business intelligence front-ends, and web-based query builders. For example, query design grids in end-user database applications let users select tables, drag fields, and define filters visually. Beyond relational data, the term "query by example" is also used in information retrieval to describe searching for documents similar to a supplied example document; that variant typically relies on vector-space representations and similarity metrics rather than SQL execution.

Distinctions and legacy

QBE is not a single standard but a user-interface paradigm and family of implementations. Its principal distinction from raw textual query languages is the shift of complexity from syntax to interaction design: users express intent by demonstrating examples, and the system performs the translation. While powerful for routine tasks, QBE-style tools can hide details that matter for performance or advanced operations. Nevertheless, the approach remains influential: many modern database front-ends and reporting tools still adopt QBE-like components to lower the barrier to data access and exploration.

For further reading, see basic materials about databases, query languages, relational models such as relational databases, historical accounts of early systems at IBM, the role of parsers in query translation (parser), and the information-retrieval meaning of QBE (information retrieval).