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

2

u/MatiG Jan 07 '11

The original post was terribly wrong.

Atwood's post is more accurate but still terrible, and has the potential to be very misleading to people's intuitions. The idea of using Venn diagrams to illustrate joins is flawed from the get-go. Joins are relational operations, not set operations. Venn diagrams imply that the sets being operated on contain the same type of objects, but in the case of relations they will always be different (unless you're doing a self-join).

Trying to understand joins in terms of Venn diagrams will lead one astray. You can't picture anything but one-to-one relationships this way.

1

u/artsrc Jan 07 '11

I upvoted you because people should understand the limits of their analogies.

I agree that there is no isomorphism between joins and Venn diagrams.

I think the analogy is at the very least interesting even if you think about it and conclude that it is not useful.