Databases Querying Relational Databases Database Normalization Set Theory and Relational Databases

Noah Fields
Noah Fields
13,985 Points

"Except", not XOR?

I thought the term for finding all instances belong in Set A, and all instances which belong in Set B, but not any instances that belong to both A and B, was referred to as an Exclusive Or, or XOR for short. Here, it's referred to as an "except". Am I incorrect? Are there certain instances which one of the two terms is more accurate or correct? What difference, if any, is there between the meaning of the two terms?

1 Answer

Steven Parker
Steven Parker
203,121 Points

EXCEPT is not the same concept as XOR.

Both would return items from set A that are not in set B. But XOR would also return items from set B that are not in set A, where EXCEPT would not return any items from set B at all.

In set theory, this is called a "difference". The set theory equivalent of XOR is a "symmetric difference".

Missy Kailet
Missy Kailet
4,393 Points

A quick question on this response: Does that mean that on the example used in the course for Apple People and Banana People, the Except column would return only Jan and Stacey, and not Jan, Stacey, and Dante? I'm just trying to make sure I understand, as it seems from your answer that the examples shown in the lesson were for XOR, not EXCEPT.

Steven Parker
Steven Parker
203,121 Points

Yes, that's right. I don't know of any set operator that performs what is shown in that video. But here's an example showing what an EXCEPT actually does:

except example

I submitted a bug report about the video to the support folks.