Question

I understand that the Cartesian product(X) operation on two databases does not need to be UNION compatible.So,if there is a same attribute called name in the two relations R and S where name in R is the first name and name in S is the second name

How can the related values be identified by the following selection operation

Q=RxS

I want to get the set of tuples whose firstname=lastname,So how am i supposed to write the selection statement?

σ Name=Name(Q)

Will this be a problem using the same attribute name in the selection operation?

Was it helpful?

Solution 2

Correct that for Cartesian product the relations need not be UNION compatible. But they still need to be compatible! Otherwise there are exactly the difficulties you point out. So the rule for Cartesian product is that there must be no attributes in common.

So if you have a clash of attributes, first you must rename the attributes before crossing. See http://en.wikipedia.org/wiki/Relational_algebra on 'Natural Join'. (That defines Nat Join in terms of Rename, Cartesian product and Projection.)

From the point of view of learning the RA, I would think of Natural Join as the basic operation. And Cartesian product as a degenerate form when there are no attributes in common. This is for example the approach that Date & Darwen take in their textbooks.

OTHER TIPS

Cartesion product does not require attributes to be named differently. It only requires relations to be named differently.

For example, D := A(id, name) X B(id, age) is perfectly valid, and the resulting relation is D(A.id, name, B.id, age).

In other words, the attributes are automatically renamed by prepending the relation name, as part of the cartesion product. This prepend operation also leads to the requirement that relations to be named differently.

Source: - Database System Concepts 6th Edition, Chapter 6.1.1.6 The Cartesian-Product Operation, for the definition, and an example in Figure 6.8 Result of instructor × teaches.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top