Michael Mior
June 23, 2023
83

# Relational Playground: Teaching the Duality of Relational Algebra and SQL

Students in introductory data management courses are often taught how to write queries in SQL. This is a useful and practical skill, but it gives limited insight into how queries are processed by relational database engines. In contrast, relational algebra is a commonly used internal representation of queries by database engines, but can be challenging for students to grasp. We developed a tool we call Relational Playground for database students to explore the connection between relational algebra and SQL.

June 23, 2023

## Transcript

and SQL
2. ### • Relational Algebra and SQL • Query Optimization • Demo

• Future Work
3. ### Context ▸ Introductory courses in databases (big data) for grads

and undergrads ▸ Relational algebra is taught ﬁrst, followed by SQL ▸ Students are expected to know how to convert between the two 3
4. ### Relational Algebra ▸ Gives a better intuition for how queries

are executed by the database ▸ Important for understanding query optimization ▸ Enabling students to experiment provides an inﬁnite source of examples 4
5. ### SQL ▸ Many students come with some knowledge of SQL

▸ Most students will likely be writing SQL ▸ Being able to connect this with relational algebra improves understanding of query execution 5
6. ### Relational Playground ▸ Currently Relational Playground supports SELECT, JOIN, WHERE,

and ORDER BY ▸ Relational Playground provides a single implementation for each operator ▸ All queries are executed completely in the browser (there is no backend) 6
7. ### Query optimization Start with a “canonical” relational algebra representation: 1.

Join all tables in the query 2. Apply any ﬁltering 3. Sort the results 4. Project the ﬁnal set of columns 7
8. ### Future Work ▸ Additional operators and expanded query support ▸

More query optimizations ▸ Explainable query execution ▸ Detailed student evaluations 8