Principles of Query Visualization

Wolfgang Gatterbauer, Cody Dunne, H. V. Jagadish, Mirek Riedewald

TL;DR

This paper introduces Query Visualization (QV) as a method to graphically represent SQL queries, aiming to improve user understanding of query intent and structure. It argues that QV complements, rather than replaces, textual query languages and presents design principles for effective QV, supported by a user study showing significant speedups in query interpretation.

What Problem Does This Paper Address?

Understanding complex SQL queries is a significant challenge for many users, even experienced ones. While Visual Query Languages (VQLs) exist for composing queries visually, there's a gap in tools that help users understand existing queries. This is crucial for tasks like reusing past queries, debugging, and learning from examples. The paper highlights that modifying existing queries is often easier than writing from scratch, but this requires comprehension. The difficulty in reading and understanding SQL, even with pretty-printers, necessitates alternative approaches like visualization.

Methods

The paper proposes Query Visualization (QV) as a technique to transform textual SQL queries into graphical representations. The core idea is to create a visual "alphabet" and metaphors that highlight the relational patterns and intent of a query, abstracting away from syntactic details. Key principles guiding their design include:

  • Familiar Metaphors: Leveraging existing notations like UML for database schemas.
  • Compositionality: Emphasizing that queries take tables as input and produce tables as output.
  • Progressive Complexity: Designing visual elements that scale with query complexity, starting with common constructs.
  • Exposing Relational Patterns: Preserving the underlying relational structure rather than abstracting it away.
  • Minimal Visual Complexity: Aiming for clarity and conciseness.
  • Abstracting Syntax: Moving beyond SQL-specific quirks like NULLs to focus on logical interpretation.
  • Output-Oriented Reading Order: Structuring the visualization to read from the output back to the input.

They introduce two variants of their visualization system: QueryVis and Relational Diagrams, which differ in how they encode nesting structures. A user study was conducted to evaluate the effectiveness of QueryVis compared to SQL alone.

Datasets

Not discussed in the paper. The paper focuses on the principles and design of query visualization and presents scenarios and a user study using existing SQL queries.

Key Insights and Ideas

  • Interpretation vs. Composition: Humans are generally better at interpreting visual information in parallel than composing it sequentially. This makes visualization ideal for understanding queries, not for writing them.
  • QV as a Complement: Query Visualization is presented as a tool to aid understanding, not replace SQL. It works alongside textual queries, providing a different perspective.
  • Beyond Query Plans: Query visualization focuses on WHAT a query does (its intent and relational pattern), distinct from query plan visualization, which explains HOW a query is executed.
  • The Power of Visual Metaphors: Using familiar visual elements (like UML) and designing for progressive complexity can make QV accessible and learnable.
  • Abstraction from Syntax: Focusing on the logical interpretation and set semantics of queries, rather than SQL-specific syntax (like NULL handling), leads to more robust and universally understandable visualizations.
  • User Study Validation: The study provides empirical evidence that QV can significantly improve query understanding speed.

Key Results

A user study involving 42 participants showed that:

  • Users were, on average, 20% faster (-20% time difference) when using QueryVis compared to SQL alone for interpreting queries.
  • There was weak evidence that users made fewer errors (-21% error difference) using QueryVis than SQL.

The paper also qualitatively describes scenarios where QV can assist data scientists in reusing queries, understanding complex patterns, and debugging.

Limitations and Future Work

The authors acknowledge several challenges and areas for future work:

  • Extensions: Handling logical disjunctions, aggregates, outer joins, NULLs, and recursion in visualizations remains challenging.
  • Relational Patterns: Formalizing the concept of "relational query patterns" is an ongoing area of research.
  • Visual Conciseness Metrics: Developing robust metrics to quantify visual complexity and conciseness, considering audience familiarity (e.g., with UML).
  • Automatic Layout Algorithms: Improving algorithms for arranging complex, layered graphs with nested hierarchies.
  • Interactive Diagrams: Exploring deeper integration between textual queries and visualizations, such as interactive mouse-overs for correspondences and auto-completion features.
  • Combinations with Other Modalities: Investigating how QV can be combined with Natural Language, example data, or operator-by-operator translations.
  • User Studies: Conducting more extensive, longitudinal studies to observe long-term learning and familiarity effects.
  • Extending to Other Languages: Applying QV principles to other declarative languages like Datalog.

Summary updated

BibTeX
@inproceedings{gatterbauer2022principles,
  author = {Wolfgang Gatterbauer and Cody Dunne and H. V. Jagadish and Mirek Riedewald},
  title = {{Principles of Query Visualization}},
  booktitle = {IEEE Data Eng. Bull},
  year = {2022},
  url = {https://openreview.net/forum?id=gb1oREfKfG9},
}
Figure