Related Experiment Video
Updated: Jan 20, 2026

Executing Complexity-Increasing Queries in Relational MySQL and NoSQL MongoDB and EXist Size-Growing ISO/EN 13606 Standardized EHR Databases
Published on: March 19, 2018
Explaining Wrong Queries Using Small Examples
Zhengjie Miao1, Sudeepa Roy1, Jun Yang1
1Duke University.
Abstract:
For testing the correctness of SQL queries, e.g., evaluating student submissions in a database course, a standard practice is to execute the query in question on some test database instance and compare its result with that of the correct query. Given two queries Q 1 and Q 2, we say that a database instance D is a counterexample (for Q 1 and Q 2) if Q 1(D) differs from Q 2(D); such a counterexample can serve as an explanation of why Q 1 and Q 2 are not equivalent. While the test database instance may serve as a counterexample, it may be too large or complex to read and understand where the inequivalence comes from. Therefore, in this paper, given a known counterexample D for Q 1 and Q 2, we aim to find the smallest counterexample D' ⊆ D where Q 1(D') ≠ Q 2(D'). The problem in general is NP-hard. We give a suite of algorithms for finding the smallest counterexample for different classes of queries, some more tractable than others. We also present an efficient provenance-based algorithm for SPJUD queries that uses a constraint solver, and extend it to more complex queries with aggregation, group-by, and nested queries. We perform extensive experiments indicating the effectiveness and scalability of our solution on student queries from an undergraduate database course and on queries from the TPC-H benchmark. We also report a user study from the course where we deployed our tool to help students with an assignment on relational algebra.
More Related Videos
05:47Evidence-based Knowledge Synthesis and Hypothesis Validation: Navigating Biomedical Knowledge Bases via Explainable AI and Agentic Systems
Published on: June 13, 2025
10:02Event Related Potentials ERPs and other EEG Based Methods for Extracting Biomarkers of Brain Dysfunction: Examples from Pediatric Attention Deficit/Hyperactivity Disorder ADHD
Published on: March 12, 2020
Related Concept Videos
Newton's Third Law: Examples
Free Body Diagrams: Examples
Kinetic Molecular Theory and Gas Laws Explain Properties of Gas Molecules
Scientific Laws and Theories
The Nitrogen Cycle
Proteins: From Genes to Degradation
Transcription is the synthesis of RNA...