We have now completed a deep dive into SQL joins. We didn’t cover absolutely everything there is to know about them, but we did cover a lot:
We now know how to join two tables together in a query, such as selecting all reminders along with the title of its associated list.
We also know how to aggregate across joins of tables. For example, we were able to select the count of all reminders in each list as just a single query. SQL is great at aggregating data like this across many tables and rows.
And finally, we dipped our toes in some more advanced queries, such as counting the number of incomplete reminders for each list, which required us to aggregate across a conditional expression and to use a left join instead of a regular join.
This is all really powerful stuff, but we also just had an entire episode without writing a single line of Swift code. I think that’s a first for Point-Free!
So now it is time to start updating our query builder to support joins. We want a simple API for joining two tables together along some constraint, and then some ability to select columns from either table, or perform predicate logic with the columns of each table, as well as ordering and aggregating across the two tables.
Let’s dig in.