SQL ↔ Algebra Quizzes
Practice both directions: write SQL for a relational-algebra-style prompt, or write algebra for a fixed SELECT query. Answers are graded by comparing result sets (never by text matching), including curated hidden datasets when available.
High achievers
List every student whose GPA is at least 3.8. Return all columns from Students (do not project yet).
High achievers
List every student whose GPA is at least 3.8. Return all columns from Students (do not project yet).
Department names only
Return the distinct department names from Departments.
Department names only
Return the distinct department names from Departments.
Alias a relation
Rename Students to S, then project student_id. Your result should list every student_id unchanged.
Alias a relation
Rename Students to S, then project student_id. Your result should list every student_id unchanged.
Employee departments
Show each employee name with their department name. Use a natural join on dept_id, then project name and dept_name.
Employee departments
Show each employee name with their department name. Use a natural join on dept_id, then project name and dept_name.
Engineering roster
List employee and department names only for the Engineering department (dept_id = 10).
Engineering roster
List employee and department names only for the Engineering department (dept_id = 10).
Rename a column
Rename Students.name to student_name, then list distinct student_name values.
Rename a column
Rename Students.name to student_name, then list distinct student_name values.
Explicit join condition
Match employees to departments using an explicit join on dept_id (theta join), then project name and dept_name.
Explicit join condition
Match employees to departments using an explicit join on dept_id (theta join), then project name and dept_name.
Full cross product
List every combination of employee name and department name using Cartesian product (expect four rows).
Full cross product
List every combination of employee name and department name using Cartesian product (expect four rows).
All people names
Build the set of distinct names appearing in either Students or Professors (one column: name).
All people names
Build the set of distinct names appearing in either Students or Professors (one column: name).
Double enrollees
Find student_id values enrolled in both course 101 and course 102.
Double enrollees
Find student_id values enrolled in both course 101 and course 102.
Everyone but independents
List student_id values enrolled in at least one course, excluding those enrolled only in course 999 (Independent Study).
Everyone but independents
List student_id values enrolled in at least one course, excluding those enrolled only in course 999 (Independent Study).
Students without majors
Show every student_id with their major_name, including students with no major (NULL major_name).
Students without majors
Show every student_id with their major_name, including students with no major (NULL major_name).
Right-sided coverage
Using a right outer join, list student_id and major_name for students matched to a major (unmatched left rows dropped).
Right-sided coverage
Using a right outer join, list student_id and major_name for students matched to a major (unmatched left rows dropped).
Full student–major picture
List every student_id with major_name, including students without majors (use full outer join).
Full student–major picture
List every student_id with major_name, including students without majors (use full outer join).
Completed course 101
Find student_id values who are enrolled in course 101. Use division with Enrolled and a one-row course relation for course 101.
Completed course 101
Find student_id values who are enrolled in course 101. Use division with Enrolled and a one-row course relation for course 101.
Computer Science majors
List names of students majoring in Computer Science (major_id 10). Join Students and Majors, filter, then project name.
Computer Science majors
List names of students majoring in Computer Science (major_id 10). Join Students and Majors, filter, then project name.
Each card opens one direction (Algebra → SQL or SQL → Algebra) for the same underlying exercise dataset.