SQL joins illustrated as Venn diagrams

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

This discussion critiques the use of Venn diagrams to explain SQL joins, arguing that they can lead to confusion for logical thinkers. The author emphasizes that SQL tables are not true sets due to the potential for duplicate rows, which complicates the analogy of joins as intersections. The author asserts that joins can produce entirely new types of elements, distinguishing them from traditional set operations. The conversation also touches on the need for more tagging options in forum discussions.

PREREQUISITES
  • Understanding of SQL joins, including inner joins and outer joins
  • Familiarity with set theory and basic operations on sets
  • Knowledge of SQL table structures and primary keys
  • Basic programming concepts, particularly in SQL
NEXT STEPS
  • Research the differences between SQL joins and set operations
  • Learn about SQL table structures and the role of primary keys
  • Explore advanced SQL join types, such as left joins and right joins
  • Study the implications of duplicate records in SQL databases
USEFUL FOR

SQL programmers, database developers, and educators looking to clarify the concepts of SQL joins and improve their teaching methods.

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
7K
  • · 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