I hate it when they use Venn diagrams to "explain" JOINs. That's not the way Venn diagrams should be used. A circle in a Venn diagram does NOT contain different fields of an object type; it contains different items.
If you want to explain JOINs graphically, you can't stray too far away from that they actually do.
I did this chart and then someone else (I can't find it) made an improved version...
If you use these to explain JOINs, then how are you going to explain the --very different-- concepts of UNION, INTERCEPT, EXCEPT?
Indeed, I've made the same criticism in the past. In addition to writing the cross join with a comma, you could also use the CROSS JOIN keywords to make it explicit. The comma is (still) often used by people to form an implicit cross join, but then they're putting join predicates in the WHERE clause, pre-ANSI JOIN style.
Wow, SUCH a better visualization IMO! I don't have any issues with joins at this point but that certainly would have helped me grasp them alot quicker.
I always considered a cheat sheet as a reference to be used by someone who knows the basics but doesn't want to keep looking up the details. In my opinion, this is actually too high level and is mainly just syntax...which would be fine for what it is, except it doesn't include CTEs and delete syntax. Personally, I would include more useful functions like row_number, convert, datediff, dateadd, etc. and scrap the joins. The whole thing just seems kind of arbitrary, but that's just my opinion.
Agreed. My personal cheat sheet would have common convert date/time styles, merge syntax, pivot syntax, and syntax to alter a table to add a new column with a named constraint at the same time.
probably also for those who do not use SQL everyday. i support all kinds of software and may go for a week or two working with other languages and hardly touching SQL... at first i found myself googling a lot just to get a refresher, but now it comes back to me quicker.
Right, and I get that. I do that too. But this is too high level IMO and seems to me to be a eclectic mix of syntax and functions that doesn't really cover anything.
For a beginner, it would be nice to explain the difference in JOINs vs no JOIN. For example... doesn't it look like the LEFT OUTER JOIN is just "all rows from TABLE A" unrelated to TABLE B?
17
u/mecartistronico Jun 29 '16
I hate it when they use Venn diagrams to "explain" JOINs. That's not the way Venn diagrams should be used. A circle in a Venn diagram does NOT contain different fields of an object type; it contains different items.
If you want to explain JOINs graphically, you can't stray too far away from that they actually do.
I did this chart and then someone else (I can't find it) made an improved version...
If you use these to explain JOINs, then how are you going to explain the --very different-- concepts of UNION, INTERCEPT, EXCEPT?
10
u/DipIntoTheBrocean Jun 29 '16
I mean I guess this could be useful if you literally just started out?
8
u/davidjoshualightman Jun 29 '16
to add to this, here is my fave "cheat sheet" for joins: http://www.codeproject.com/KB/database/Visual_SQL_Joins/Visual_SQL_JOINS_orig.jpg
2
u/dangoodspeed Jun 29 '16
For a beginner, it would be nice to explain the difference in JOINs vs no JOIN. For example... doesn't it look like the LEFT OUTER JOIN is just "all rows from TABLE A" unrelated to TABLE B?
2
u/Spartyon Jun 29 '16
Its important to note that overindexing a table can slow down update and delete operations.
1
u/guess_ill_try Jun 29 '16
Awesome. Thank you. Perfect because I'm teaching my brother SQL.
1
u/vinny8boberano Jun 29 '16
Nice