SQL joins illustrated as Venn diagrams

  • Thread starter Thread starter SlurrerOfSpeech
  • Start date Start date
  • Tags Tags
    Diagrams Sql Venn
Click For Summary

Discussion Overview

The discussion revolves around the use of Venn diagrams and set theory to explain SQL joins, particularly focusing on whether this approach aids or confuses learners. Participants explore the nature of SQL tables in relation to set theory and the implications for understanding joins.

Discussion Character

  • Debate/contested
  • Conceptual clarification

Main Points Raised

  • Some participants argue that using Venn diagrams to illustrate SQL joins is confusing, particularly for those with a literal or logical mindset, as SQL tables can contain repeated elements, unlike traditional sets.
  • One participant points out that while SQL tables are not sets, one could still consider them as sets for the sake of discussion, but questions the validity of using intersections to represent joins due to differing element types.
  • Another participant suggests that a join can be viewed as a subset of the product of the joined sets, indicating a different perspective on the relationship between joins and set theory.
  • There is a mention that using primary keys in SQL can address the issue of identical records, which adds a technical nuance to the discussion.
  • Several participants express a desire for more tagging options in the forum to categorize posts more effectively.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the usefulness of Venn diagrams for explaining SQL joins, with some finding it confusing and others suggesting it is a matter of personal preference. The discussion remains unresolved regarding the effectiveness of this illustrative approach.

Contextual Notes

Participants highlight the limitations of applying set theory to SQL, particularly regarding the nature of elements in SQL tables and the implications for understanding joins. The discussion reflects varying interpretations of set definitions and their applicability to SQL.

SlurrerOfSpeech
Messages
141
Reaction score
11
In my opinion, using Venn diagrams, or set theory in general, to help aspiring SQL programmers (yes, SQL is a programming language) understand joins causes nothing but confusion for literal-, logical-thinking persons like myself. Allow me to explain my opinion.

Venn diagrams have always been used to show operations on sets of elements of the same type. SQL tables are not sets because they can contain repeated elements (identical rows). But let's pretend for a moment that they are sets. Still, an inner join, for example, doesn't necessarily make sense as an intersection because the two sets being intersected do not necessarily consist of the same types of elements. The following

A = { dog, cat, horse, lizard }
B = { cat, mule, hamster, dog }
A intersect B = { cat, dog }

simple example of an intersection makes sense because the sets have the same types of elements (animal names). A join is nothing like an intersection because A and B can be of different elements and the result can be an entirely new type of element.

By the way, you guys should add more prefixes so I don't have to arbitrarily tag this as C/#/++ in order to satisfy the prefix reguirment.
 
Technology news on Phys.org
SlurrerOfSpeech said:
In my opinion, using Venn diagrams, or set theory in general, to help aspiring SQL programmers (yes, SQL is a programming language) understand joins causes nothing but confusion for literal-, logical-thinking persons like myself. Allow me to explain my opinion.

Venn diagrams have always been used to show operations on sets of elements of the same type. SQL tables are not sets because they can contain repeated elements (identical rows). But let's pretend for a moment that they are sets. Still, an inner join, for example, doesn't necessarily make sense as an intersection because the two sets being intersected do not necessarily consist of the same types of elements.
There is nothing in the definition of a set that says the elements have to be of the same type. From wikipedia, a set is "a collection of distinct objects".
SlurrerOfSpeech said:
The following

A = { dog, cat, horse, lizard }
B = { cat, mule, hamster, dog }
A intersect B = { cat, dog }
You could just as well have this:
A = { dog, 7, granite, shovel }
B = { mule, dog, pinwheel, hammer }
##A \cap B ## = {dog}
SlurrerOfSpeech said:
simple example of an intersection makes sense because the sets have the same types of elements (animal names). A join is nothing like an intersection because A and B can be of different elements and the result can be an entirely new type of element.

By the way, you guys should add more prefixes so I don't have to arbitrarily tag this as C/#/++ in order to satisfy the prefix reguirment.
 
A join can be described as a set, more precisely as a subset of the product of the joined sets.

Whether it is helpful or not is a matter of taste.

Technically an SQL table can contain identical records, using a primary key takes care of that.
 
SlurrerOfSpeech said:
By the way, you guys should add more prefixes so I don't have to arbitrarily tag this as C/#/++ in order to satisfy the prefix reguirment.
The tag is not required, but I agree that we should have more tags.

Since your post isn't about C, C++, or C#, I am removing that tag.
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
8K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
6
Views
7K
Replies
10
Views
3K
  • · Replies 4 ·
Replies
4
Views
15K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
6K
Replies
4
Views
3K