Are these two relations compatible for a union operation? Are these two relations compatible for a union operation? database database

Are these two relations compatible for a union operation?


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:

  • Person(FirstName, LastName)
  • Country(Name, Population)

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.


In fact, these two relations are not compatible for a union: they have a different number of attributes. Found the answer after some more research.


Two table are said to be union compatible if both the table have same number of attributes (column) and corresponding attributes have the same data type (int,char,float,date etc.). Corresponding attributes means first attributes of both relations, then second and soon.

union compatible:
A: (First_name (char), Last_name(char), Date_of_Birth(date))
B: (FName(char),LName(char),DOB(date))
Both table have 3 attributes and of same date type.

Not compatible:
A: (First_name (char), Last_name(char), Date_of_Birth(date))
B: (FName(char),LName(char),PhoneNumber(number))

(The third attributes are different.)