Enhancing Automatic Grading of SQL Query Assignments Using Generative AI: A Case Study on SPJ Query Assignment

Open Access

Abstract: The grading of SQL query assignments is a time-consuming task for instructors, especially in large classes where ensuring both accuracy and consistency is difficult. In this paper, we develop and evaluate an automatic grading tool for SQL query design using generative AI. The system targets SPJ (Selection, Projection, Join) query tasks from the Information Systems Experiment course. By incorporating model answers, lecture materials, and common student errors into carefully designed prompts, the tool aimed to improve grading accuracy and the quality of feedback. Comparative experiments were conducted using different prompt configurations and an existing rubric-based tool developed by Ando et al. The results demonstrated that the optimized GPT-based prompt design achieved 96.8% accuracy (387 out of 400 items correctly graded) and provided detailed feedback specifying “what was wrong,” “why,” and “how to fix it.” This feedback was found to support student learning and reduce grading inconsistencies for instructors. The findings confirm the potential of GPT-based systems as effective complements to existing rubric-based methods. This research highlights the promise of generative AI in delivering scalable, fair, and pedagogically meaningful assessments in database education.

Keywords: Generative AI, GPT, automatic grading, SQL query design, educational technology, prompt engineering