Skip to main content
Quiz mode

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.

Quiz direction
Difficulty
Operator focus
BeginnerAlgebra → SQLSelection (Restrict)

High achievers

List every student whose GPA is at least 3.8. Return all columns from Students (do not project yet).

BeginnerSQL → AlgebraSelection (Restrict)

High achievers

List every student whose GPA is at least 3.8. Return all columns from Students (do not project yet).

BeginnerAlgebra → SQLProjection

Department names only

Return the distinct department names from Departments.

BeginnerSQL → AlgebraProjection

Department names only

Return the distinct department names from Departments.

BeginnerAlgebra → SQLRelation Rename

Alias a relation

Rename Students to S, then project student_id. Your result should list every student_id unchanged.

BeginnerSQL → AlgebraRelation Rename

Alias a relation

Rename Students to S, then project student_id. Your result should list every student_id unchanged.

BeginnerAlgebra → SQLNatural Join

Employee departments

Show each employee name with their department name. Use a natural join on dept_id, then project name and dept_name.

BeginnerSQL → AlgebraNatural Join

Employee departments

Show each employee name with their department name. Use a natural join on dept_id, then project name and dept_name.

BeginnerAlgebra → SQLSelection (Restrict)

Engineering roster

List employee and department names only for the Engineering department (dept_id = 10).

BeginnerSQL → AlgebraSelection (Restrict)

Engineering roster

List employee and department names only for the Engineering department (dept_id = 10).

BeginnerAlgebra → SQLAttribute Rename

Rename a column

Rename Students.name to student_name, then list distinct student_name values.

BeginnerSQL → AlgebraAttribute Rename

Rename a column

Rename Students.name to student_name, then list distinct student_name values.

IntermediateAlgebra → SQLTheta Join (Conditional Join)

Explicit join condition

Match employees to departments using an explicit join on dept_id (theta join), then project name and dept_name.

IntermediateSQL → AlgebraTheta Join (Conditional Join)

Explicit join condition

Match employees to departments using an explicit join on dept_id (theta join), then project name and dept_name.

IntermediateAlgebra → SQLCartesian Product (Cross Join)

Full cross product

List every combination of employee name and department name using Cartesian product (expect four rows).

IntermediateSQL → AlgebraCartesian Product (Cross Join)

Full cross product

List every combination of employee name and department name using Cartesian product (expect four rows).

IntermediateAlgebra → SQLSet Union

All people names

Build the set of distinct names appearing in either Students or Professors (one column: name).

IntermediateSQL → AlgebraSet Union

All people names

Build the set of distinct names appearing in either Students or Professors (one column: name).

IntermediateAlgebra → SQLSet Intersection

Double enrollees

Find student_id values enrolled in both course 101 and course 102.

IntermediateSQL → AlgebraSet Intersection

Double enrollees

Find student_id values enrolled in both course 101 and course 102.

IntermediateAlgebra → SQLSet Difference

Everyone but independents

List student_id values enrolled in at least one course, excluding those enrolled only in course 999 (Independent Study).

IntermediateSQL → AlgebraSet Difference

Everyone but independents

List student_id values enrolled in at least one course, excluding those enrolled only in course 999 (Independent Study).

IntermediateAlgebra → SQLLeft Outer Join

Students without majors

Show every student_id with their major_name, including students with no major (NULL major_name).

IntermediateSQL → AlgebraLeft Outer Join

Students without majors

Show every student_id with their major_name, including students with no major (NULL major_name).

AdvancedAlgebra → SQLRight Outer Join

Right-sided coverage

Using a right outer join, list student_id and major_name for students matched to a major (unmatched left rows dropped).

AdvancedSQL → AlgebraRight Outer Join

Right-sided coverage

Using a right outer join, list student_id and major_name for students matched to a major (unmatched left rows dropped).

AdvancedAlgebra → SQLFull Outer Join

Full student–major picture

List every student_id with major_name, including students without majors (use full outer join).

AdvancedSQL → AlgebraFull Outer Join

Full student–major picture

List every student_id with major_name, including students without majors (use full outer join).

AdvancedAlgebra → SQLRelational Division

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.

AdvancedSQL → AlgebraRelational Division

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.

AdvancedAlgebra → SQLNatural Join

Computer Science majors

List names of students majoring in Computer Science (major_id 10). Join Students and Majors, filter, then project name.

AdvancedSQL → AlgebraNatural Join

Computer Science majors

List names of students majoring in Computer Science (major_id 10). Join Students and Majors, filter, then project name.

AdvancedAlgebra → SQLNatural Join

Heavy course load

Find student_id values enrolled in at least one course with credits ≥ 4. Join Enrolled and Courses, filter, project student_id distinct.

AdvancedSQL → AlgebraNatural Join

Heavy course load

Find student_id values enrolled in at least one course with credits ≥ 4. Join Enrolled and Courses, filter, project student_id distinct.

Each card opens one direction (Algebra → SQL or SQL → Algebra) for the same underlying exercise dataset.