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
1m 11s
Input Tokens
947
Output Tokens
186
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 lessons ADD CONSTRAINT unique_course_lesson UNIQUE (course_id, lesson_id);
ALTER TABLE completions ADD COLUMN course_id INT NOT NULL;
ALTER TABLE completions ADD CONSTRAINT fk_completions_lesson_course FOREIGN KEY (course_id, lesson_id) REFERENCES lessons (course_id, lesson_id);
ALTER TABLE completions ADD CONSTRAINT fk_completions_enrollments FOREIGN KEY (user_id, course_id) REFERENCES enrollments (user_id, course_id);