~/devreads

#join

6 posts

4 May

lukaseder 1 min read

Some SQL operators are as esoteric as they’re powerful. One of the oldest operator that you’ve likely hardly ever used in real world applications is NATURAL JOIN which is the default in relational algebra. We’ve covered a funky use-case for NATURAL JOIN earlier on this blog. The main reason why it’s not very useful is … Continue reading Why JOIN…

sqljoin

21 Jun 2023

vladmihalcea 1 min read

Introduction In this article, we are going to see how we can fetch multiple to-many relationships with jOOQ MULTISET so that we avoid bumping into an unintentional Cartesian Product. The approach taken by jOOQ is truly revolutionary since it offers a solution that allows you to fetch multiple to-many relationships using a single type-safe query. Domain Model Let’s assume that…

jooqcartesian productjoinmany-to-manymultiple

9 Apr 2019

lukaseder 1 min read

A question that is frequently occurring among my SQL training‘s participants is: What’s the difference between putting a predicate in the JOIN .. ON clause and the WHERE clause? I can definitely see how that’s confusing some people, as there seems to be no difference at first sight, when running queries like these, e.g. in … Continue reading The Difference…

sqljoinjoin .. ononpredicate

16 Mar 2017

lukaseder 1 min read

There are many many opinions out there regarding the old surrogate key vs. natural key debate. Most of the times, surrogate keys (e.g. sequence generated IDs) win because they’re much easier to design: They’re easy to keep consistent across a schema (e.g. every table has an ID column, and that’s always the primary key) They’re … Continue reading Faster SQL…

sqljoinjoin performancenatural keyoptimisation

12 Jan 2017

lukaseder 1 min read

Perhaps the most powerful SQL feature is the JOIN operation. It is the envy of all non-relational databases, because the concept is so simple, yet so universally applicable, when you want to “combine” two data sets. Put simply, when joining two tables, you’re combining every row from one table with every row from another table, … Continue reading A Probably…

sqlcross joininner joinjoinjoin using

6 Oct 2015

lukaseder 1 min read

When people talk about SQL JOIN, they often use Venn Diagrams to illustrate inclusion and exclusion of the two joined sets: While these Venn diagrams are certainly useful to understand (and remember) SQL JOIN syntax, they’re not entirely accurate, because SQL JOIN is a special type of a cartesian product, the CROSS JOIN. In a … Continue reading You Probably…

sqlcartesian productexceptintersectjoin