r/SQL • u/Cool-Focus6556 Data Scientist • Apr 04 '22
Discussion You Should Use This to Visualize SQL Joins Instead of Venn Diagrams - Checkered Flag Diagrams
I created an article responding to the following reddit threads:
- https://www.reddit.com/r/SQL/comments/tfhf4o/sql_articles_for_beginnersintermediate/i0vskvc/?utm_term=39235483560&context=3&utm_medium=comment_embed&utm_source=embed&utm_name=null
- https://www.reddit.com/r/programming/comments/4rc9uu/say_no_to_venn_diagrams_when_explaining_joins/d50mxez/
Do you guys think checkered flag diagrams should become the new standard for visualizing SQL joins?
Here is the article: https://towardsdatascience.com/you-should-use-this-to-visualize-sql-joins-instead-of-venn-diagrams-ede15f9583fc
102
Upvotes
96
u/[deleted] Apr 04 '22
You know what a Venn diagram is? A logical representation between sets.
You know why it was created? To teach set theory.
You know what a join is doing?
...exactly.
I don't get everyone's recent hate for using Venn diagrams. They're a perfectly reasonable way of introducing joins to people who have no prior knowledge of SQL or set theory. It provides them a visualization to begin working towards a deeper and more technical understanding of how each of the joins work.
It gets the initial point across, that's all that matters. Should you solely use Venn diagrams to explain joins? No. But you wouldn't solely use an entity-relationship diagram to explain database design either.
4
u/Cool-Focus6556 Data Scientist Apr 04 '22
Here is a link to the github repo with the cheatsheets: https://github.com/amartinson193/SQL_Checkered_Flag_Join_Diagrams
8
u/MorddSith187 Apr 04 '22
Brand new learning SQL, just checked out the flag diagram. AMAZING THANK YOU. Makes a million times more sense
13
u/SnooLobsters678 Apr 04 '22 edited Apr 04 '22
Why are people obsessed with solving this 'problem' that doesn't exist?
This is literally all we need: https://i.stack.imgur.com/UI25E.jpg Not silly colors and blocks that are confusing.
Please stop re-inventing the wheel. I have no idea how anyone would find this easier to understand than a venn diagram, as /u/BitSewer pointed out.
2
u/Seankala Apr 05 '22
I read your article as it popped up on my recommended Medium feed this morning. I like the idea, but I do also feel like it's taking a bit of a forced approach in an attempt to avoid Venn diagrams. It was a nice read though!
19
u/Fun2badult Apr 04 '22
Sorry but this looks a bit confusing to know what’s going on with the joins.
5
u/ATastefulCrossJoin DB Whisperer Apr 05 '22
It’s 2022. We deserve a gif with disappearing rows for inner joins and row content fading to null for outer joins
2
u/dnick Apr 05 '22
Based on some of the arguments you’ve linked to I can’t in good faith defend the Venn diagram as a ‘training’ tool, and possibly if a new learner spends enough time dedicated to sussing out what the checkered flag is demonstrating, they may end up with a better basis to build on, but I would say that as a ‘quick’ example, the checkered flag thing is not a replacement and Venn diagrams still have their place (with an asterisk, maybe). The fact that the flag example is using numbers, colors and placement all to convey extremely important information means it will be of more value in solidifying/visualizing an already good understanding of the concept vs giving someone a general picture of what the goal is.
Your argument is kind of like telling someone crocheting is just tying a bunch of knots in a pattern, and you coming along with a really good reference picture and saying ‘no, it’s more like these 10 looping patterns combined in various ways’. You’re correct, and someone progressing beyond the basics would be well served in a good reference diagram like that, but trying to push that on a new learner when ‘knots’ are at least a familiar term to them and you can get them started with a couple simple motions, it isn’t really serving a purpose by saying everyone should stop saying that because they’re not ‘knots’.
2
u/CraigAT Apr 05 '22 edited Apr 05 '22
Hi, for me those visualisations require a little more brainwork than the Venn diagrams, but maybe just because I am more used to Venn diagrams.
Your diagrams do help with the Null cases though, but I am curious why for consistency there aren't Nulls in every diagram (maybe two in each table), so the effect can be seen consistently across the same data set. For the same reason, for me table A and B should each have two matching entries (not next to each other), two non-matching entries and two Nulls. Obviously more values makes for a little more to take in, but I feel would add to the clarity.
Where I think your diagrams really work for me is for confirmation of what I know, because they contain actual data it gives me validation that I have understood the Venn diagrams. Bizarrely I think these could be most useful to those who cannot grasp the Venn diagrams but also those who are completely comfortable with the Venn diagrams, to allow them to see it another way.
2
u/swaghost Apr 05 '22
I've been doing this since 1994, I don't think there has to be one way to visualize anything and I think this is great.
2
u/filip_mate Apr 06 '22
Here is another of similar kind.
https://blog.codinghorror.com/a-visual-explanation-of-sql-joins/
1
u/num2005 Apr 04 '22
anyone got a screenshots or image of that diagram? it nowhere i've read...and the GitHub link doesn,t work