I'm not sure if the following two relations are compatible for a union:
R: <- schema name
B
1
2
2
3
3
And:
Q: -< schema name
A B
5 1
6 1
4 2
3 4
I want to do the union: Q U R. Can I? What's the result?
The union operator requires that both relations are union-compatible. This means that they are required to have the same set of attributes. Note that this concept goes slightly beyond than sharing the same amount of attributes. This is because it also considers the content of the attribute.
This doesn't mean that both attributes should have the same name but rather that both attributes should, and I'm really walking away from relational algebra with this example, have a similar "data type". There is no such a thing in relation algebra but I think that if you have a programming background you'll easily get it by thinking on that concept.
EG: Consider the following relations:
In this case, Person and Country are not union-compatible as they do not share the same set of attributes, even though they share the same amount of attributes.