Idea · Sep 27, 2026
SQL Counterexample Grader
An SQL autograder that, instead of just saying 'wrong result', generates the smallest database instance where the student's query and the reference query disagree and shows it side by side.
What it would do
Result-table grading on a fixed sample database misses many wrong queries (a missing DISTINCT or a LEFT vs INNER JOIN often produces the same rows on the instructor's data). SQL Counterexample Grader runs the student query and the reference against a battery of generated database instances, built with mutation-killing heuristics in the spirit of XData: NULLs in join columns, duplicate rows, empty groups, ties at LIMIT boundaries. When the two queries disagree, it shrinks the instance to a minimal counterexample (often three to five rows) and shows both result tables with the differing rows highlighted. An optional LLM layer writes a solution-free hint that points at the relevant clause and the relevant rows, never at the fix. Everything runs in the browser on SQLite compiled to WebAssembly, so instructors can host it statically.
Key features
- Instance generator with targeted cases for NULLs, duplicates, empty groups, outer joins, and ORDER BY/LIMIT ties
- Delta-debugging shrinker that reduces a disagreeing database to a minimal counterexample
- Side-by-side result diff with highlighted rows and the clause most likely responsible
- Optional solution-free hint from Claude API with a leakage check that rejects hints containing reference SQL fragments
- Assignment pack format (schema, reference queries, point weights) exportable as JSON and a Canvas-friendly CSV of scores