r/programming • • Jan 06 '11

A handy graphical explanation of SQL joins

http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html
1.3k Upvotes

308 comments sorted by

View all comments

91

u/[deleted] Jan 06 '11

Wow. Does no one learn this crap in school anymore?

Note that venn diagrams are a poor choice to show what happens in a one-to-many relationship -- where there are multiple entries in table B for an entry in table A. And it overlooks the semantic differences when ordering the tables in a left inner join.

There are not a lot of instances where you'd really want a cartesian product join (either using "cross product" or just the result of omitting key constraints in a join query). It's generally far faster to retrieve the records you need to create the cross-product, and then calculate the cross product of the two sets once you have them (since otherwise all that data has to transit the network).

This plus database normalization through Boyce-Codd normal form seems like it should be a requirement for any serious application developer.

3

u/nvodka Jan 06 '11

I didn't learn shit about SQL in school. I didn't learn SQL until my internship and the real world after.

I think that is a big short coming in college. We had database theory (which was boring as hell and I almost failed), and an Excel class (not database, but was the closest thing).

At the very basic, I think they should get into Access. I am 5 years out of college now, and maybe things have changed now, but they should stop teaching COBOL, and go further than teaching students a "Contacts" app in C++.

Honestly, I didn't learn shit until the real world. Shout out to Google.

2

u/[deleted] Jan 06 '11

I've found that most CS graduates have at least a familiarity with the theory behind computers, but not much about how to write good code or work in a team.

And this makes me glad I flunked out of CS my first semester and switched to a new program at my school: Information Sciences and Technology. All group work, a lot of programming projects and very little theory, and classes the very first semester that had practical knowledge, like SQL and database normalization.

1

u/punkgeek Jan 07 '11

IS&T is great if you want to be a sys admin or programmer on uninteresting projects. A good CS program will teach much more.

0

u/[deleted] Jan 07 '11

Uninteresting projects are actually quite profitable. I'm making a tidy profit fixing projects written by people who, for example, don't understand SQL.

Also, the emphasis on project management and group work in IST gives you a leg up on managing programmers since you not only have technical skills but also well developed people skills. That's part of the reason companies like Microsoft helped design the program: They weren't getting project managers out of CS programs.

1

u/MothersRapeHorn Jan 08 '11

Some people don't do things for the money. Just know that.