Comparing relational languages by their logical expressiveness is well understood. Much less is understood about how to compare them by their ability to represent relational query patterns. Indeed, what are query patterns other than “a certain way of writing a query?” And how can query patterns be defined across procedural and declarative languages, irrespective of their syntax?

We provide what is, to the best of our knowledge, the first semantic definition of relational query patterns, using a variant of structure-preserving mappings between the relational tables of queries. This formalism lets us analyze the relative pattern expressiveness of relational language fragments and derive a hierarchy of languages that share the same logical expressiveness but differ in pattern expressiveness.

To develop an intuitive understanding of query pattern, consider the following three queries: “Find sailors who reserved all red boats”, “Find students who took all classes from the art department”, and “Find actors who appeared in all Hitchcock films.” Although they are posed over 3 different schemas, these queries share the same relational pattern, shown in the “all” column:

Relational Diagrams are a complete and sound diagrammatic representation of safe relational calculus. They are (𝑖) proven unambiguous, (𝑖𝑖) proven relationally complete, and (𝑖𝑖𝑖) able to represent all relational query patterns for unions of non-disjunctive queries (SIGMOD'24). The recent extension, RepresentationB (SIGMOD'26), makes them pattern-complete for full relational calculus. Our anonymously preregistered user study shows that Relational Diagrams allows users to recognize patterns meaningfully faster and with higher accuracy across different schemas than SQL.

We envision a future in which users can dictate queries to a relational database, and the system visualizes them in real time so users can verify that the intended meaning has been captured.




SIGMOD'24

On the Reasonable Effectiveness of Relational Diagrams: Explaining Relational Query Patterns and the Pattern Expressiveness of Relational Languages
SIGMOD 2024 honorable mention (announcement)
This paper proposes a semantic definition of relational query patterns, which allows us to analyze the relative pattern expressiveness of relational query languages. It also introduces Relational Diagrams as diagrammatic representation of tuple relational calculus. In an anonymously preregistered user study, users understood relational patterns faster and more accurately with Relational Diagrams than with SQL.


CIDR'26

Database Research needs an Abstract Relational Query Language
Wolfgang Gatterbauer, Diandre Sabale
We introduce Abstract Relational Calculus (ARC), a relational reference language that separates a query's relational pattern from its modalities and conventions. We see it as the Rosetta Stone of relational languages, targeted towards both the human and machine audiences.


Funding

This work has been supported in part by the National Science Foundation (NSF) under award numbers IIS-1762268, IIS-1956096, and IIS-2145382, and was conducted in part while Wolfgang Gatterbauer was on sabbatical and attending the semester-long program on Logic and Algorithms in Database Theory and AI at Berkeley's Simons Institute for the Theory of Computing. Any opinions, findings, and conclusions or recommendations expressed in this project are those of the authors and do not necessarily reflect the views of the Funding Agencies.

National Science Foundation Simons Institute for the Theory of Computing

Closely Related Papers

A Tutorial on Relational Language Design
Wolfgang Gatterbauer
SIGMOD tutorials 2026 (to appear)
A Principled Solution to the Disjunction Problem of Diagrammatic Query Representations
Wolfgang Gatterbauer
SIGMOD 2026 (to appear).
Solves the problem of deriving a principled pattern-preserving diagrammatic representation for full first-order logic.
Relational Diagrams and the Pattern Expressiveness of Relational Languages
Wolfgang Gatterbauer, Cody Dunne
Summarizes the two results from our SIGMOD 2024 paper: a precise semantic definition of relational query patterns and a short self-contained translation from SQL to Relational Diagrams.
A Comprehensive Tutorial on over 100 Years of Diagrammatic Representations of Logical Statements and Relational Queries
Wolfgang Gatterbauer
Surveys the key visual metaphors developed for visual representations of relational expressions, including the early history predating the relational model. Also includes a detailed comparison of Relational Diagrams against formalisms such as Venn-Peirce diagrams, Beta Existential Graphs and Conceptual Graphs.
A Tutorial on Visual Representations of Relational Queries
Wolfgang Gatterbauer
An earlier tutorial that surveys the key visual metaphors developed for visual representations of relational expressions inside the database community, leaving out the early history and connections to diagrammatic reasoning.
Principles of Query Visualization
Wolfgang Gatterbauer, Cody Dunne, H.V. Jagadish, Mirek Riedewald
Discusses principles for relational query visualization and potential of visual representations for simplifying the user interactions with relational data.
Stratisfimal Layout: A Modular Optimization Model for Laying out Layered Node-Link Network Visualizations
Sara Di Bartolomeo, Mirek Riedewald, Wolfgang Gatterbauer, and Cody Dunne
Proposes a comprehensive approach to make complicated networks (such as those with layers and grouped nodes) easier to read. The idea is to formulate various readability criteria (notably crossing minimization and bendiness reduction) as a modular and customizable constraint optimization problem.
QueryVis: Logic-based Diagrams help Users Understand Complicated SQL Queries Faster
Aristotelis Leventidis, Jiahui Zhang, Cody Dunne, Wolfgang Gatterbauer, HV Jagadish, Mirek Riedewald
SIGMOD reproducibility award (1/3) (announcement)
Shows that logical diagrams automatically created from SQL queries help users understand the queries faster and with fewer errors than SQL itself. Our ultimate goal is to allow users of SQL to reason about queries in terms of "diagrammatic SQL patterns" based on first-order logic.
QueryViz: Helping users understand SQL queries and their patterns
Jonathan Danaparamita, Wolfgang Gatterbauer
Proposes QueryVis (former QueryViz), a lightweight add-on to existing databases. Copy your SQL query into the interactive interface at http://queryvis.com and look at the visualization of the query's relational pattern.
Databases will visualize queries too
Wolfgang Gatterbauer
Describes a new human-query interaction in which users reuse existing queries as templates to compose their own queries. This interaction is made possible with new automatic query visualization tools (such as QueryViz, or now QueryVis) which help users understand SQL patterns quickly.

Related web pages

Surveys the key visual metaphors developed for visual representations of relational expressions, including the early history predating the relational model
Surveys the key visual metaphors developed for visual representations of relational expressions.
A modular optimization model for layered node-link network visualizations, as needed for query visualizations
Precursor to Relational Diagrams