SQL

Natural language to SQL query generation evaluates text-to-query fidelity and schema reasoning. This task is particularly relevant for analytics chat assistants and simplified database interfaces where users need to query data using natural language. Models must understand both the intent behind the question and the structure of the underlying database schema.

100
Duration
5s
Input Tokens
1518
Output Tokens
176
Cost
$0.00
Context
Input
Add a foreign key from completions to enrollments, linking through user_id and course_id to ensure data consistency.
Expected output
ALTER TABLE completions ADD COLUMN course_id INT, ADD CONSTRAINT fk_completions_user_course FOREIGN KEY (user_id, course_id) REFERENCES enrollments(user_id, course_id);
Model output
ALTER TABLE completions ADD COLUMN course_id INT; UPDATE completions SET course_id = (SELECT course_id FROM lessons WHERE lessons.lesson_id = completions.lesson_id); ALTER TABLE completions ADD CONSTRAINT fk_completions_enrollments FOREIGN KEY (user_id, course_id) REFERENCES enrollments(user_id, course_id);