When there exists two sets, R and S, and we take the difference R - S, we remove the elements from R that exist in S.

For cases where the number of columns are the same on both sides, such as the example below, this works fine:

enter image description here


However, what happens when R and S have a different amount of columns?

  • Why are images of text, code and mathematical expressions discouraged? Please put everything needed to ask your question in your post (using text for what can be given in text), not just at a link.
    – philipxy
    Commented Feb 19, 2023 at 20:06
  • Relational algebra <> set algebra. So relational algebra difference <> set difference. Depending on the algebra, a relation is not necessarily characterizable as a set of tuples. There are many relational algebras. They differ in operators & even what a relation is. Give operator definitions & your reference for yours. Eg textbook name, edition & page. PS What do you mean, "what happens"? You can't use it.
    – philipxy
    Commented Feb 19, 2023 at 20:12

1 Answer 1


If I recall, the difference operation requires the two relations involved to be compatible, implying that they should have the same number of columns.

Quoting from Wikipedia about relational algebra

For set union and set difference, the two relations involved must be union-compatible—that is, the two relations must have the same set of attributes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.