Hacker News new | ask | show | jobs
by shubh2336 2618 days ago
Shouldn't joins be explained as cartesion product instead of venn diagrams [1] when co-relating with sets?

[1] https://www.textbook.ds100.org/ch/05/cleaning_structure.html...

2 comments

As I understand things, the Cartesian product (AKA the cross join) cannot be nicely depicted using Venn diagrams, you're right. However, Venn diagrams are a great way to depict the set logic that applies to the join keys of left, right, inner, and outer joins.
See here for an example of an argument against using Venn diagrams to depict joins: https://dzone.com/articles/say-no-to-venn-diagrams-when-expl...
Thanks! That link sent me down a rabbit hole in which I learned valuable things about SQL that I didn't even realize I lacked.
I thought a cartesian (cross) product produced an ordered output (tuple), an element from each set?

I don't have any experience with data science, but my brain wants to apply linear algebra and set theory...

So, in the above linked example, to clean we would first do an intersect operation on user names to remove people who don't appear in each set.

Then, to put the tables together (to append emails to appropriate names) we do a cross product between the filtered sets (assuming the sets have been ordered).

Is my intuition correct? I also have zero experience with DBs.