Skip to main content

Explaining Wrong Queries Using Small Examples.

Publication ,  Journal Article
Miao, Z; Roy, S; Yang, J
Published in: Proceedings. ACM-SIGMOD International Conference on Management of Data
June 2019

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 Q1 and Q2, we say that a database instance D is a counterexample (for Q1 and Q2) if Q1(D) differs from Q2(D); such a counterexample can serve as an explanation of why Q1 and Q2 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 Q1 and Q2, we aim to find the smallest counterexample D'D where Q1(D') ≠ Q2(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.

Duke Scholars

Altmetric Attention Stats
Dimensions Citation Stats

Published In

Proceedings. ACM-SIGMOD International Conference on Management of Data

DOI

ISSN

0730-8078

Publication Date

June 2019

Volume

2019

Start / End Page

503 / 520
 

Citation

APA
Chicago
ICMJE
MLA
NLM
Miao, Z., Roy, S., & Yang, J. (2019). Explaining Wrong Queries Using Small Examples. Proceedings. ACM-SIGMOD International Conference on Management of Data, 2019, 503–520. https://doi.org/10.1145/3299869.3319866
Miao, Zhengjie, Sudeepa Roy, and Jun Yang. “Explaining Wrong Queries Using Small Examples.Proceedings. ACM-SIGMOD International Conference on Management of Data 2019 (June 2019): 503–20. https://doi.org/10.1145/3299869.3319866.
Miao Z, Roy S, Yang J. Explaining Wrong Queries Using Small Examples. Proceedings ACM-SIGMOD International Conference on Management of Data. 2019 Jun;2019:503–20.
Miao, Zhengjie, et al. “Explaining Wrong Queries Using Small Examples.Proceedings. ACM-SIGMOD International Conference on Management of Data, vol. 2019, June 2019, pp. 503–20. Epmc, doi:10.1145/3299869.3319866.
Miao Z, Roy S, Yang J. Explaining Wrong Queries Using Small Examples. Proceedings ACM-SIGMOD International Conference on Management of Data. 2019 Jun;2019:503–520.

Published In

Proceedings. ACM-SIGMOD International Conference on Management of Data

DOI

ISSN

0730-8078

Publication Date

June 2019

Volume

2019

Start / End Page

503 / 520