4.4k views

Consider the following relations A, B and C:

A
Id Name Age
12 Arun 60
15 Shreya 24
99 Rohit 11
B
Id Name Age
15 Shreya 24
25 Hari 40
98 Rohit 20
99 Rohit 11
C
Id Phone Area
10 2200 02
99 2100 01

How many tuples does the result of the following relational algebra expression contain? Assume that the schema of $A\cup B$ is the same as that of $A$.

$$(A\cup B)\bowtie _{A.Id > 40 \vee C.Id < 15} C$$

1. 7
2. 4
3. 5
4. 9
retagged | 4.4k views
+2

what does it mean : "Assume that the schema of A∪B is the same as that of A

if A is

A
Id Name Age
12 Arun 60
15 Shreya 24
99 Rohit 11

it gives 4 tuples

or if A is

A
Id Name Age
12 Arun 60
15 Shreya 24
99 Rohit 11
 25 Hari 40 98 Rohit 20

it gives 7 tuples;

0
I have also the same doubt bro. Could anyone explain the question which says "Assume that the schema of AUB is the same as that of A?"
+6

Schema is nothing but attribute name or column names.

A U B schema

Id Name Age
0
thanks for clearing my doubt bro
+2
$(A∪B)⋈_{A.Id>40∨C.Id<15}C$ =  $(_{A.Id>40}((A∪B) \times C))$ $∪$ $(_{C.Id<15}((A∪B) \times C))$

50. For C.ID = 10, all tuples from $A \cup B$ satisfies the join condition, hence 5 tuples (union of A and B has only 5 tuples are 2 of them are repeating for Shreya and Rohit)  will be returned. Now, for C.ID = 99,  A.ID = 99 and A.ID = 98 (for A.ID = 98, we need to assume A ∪ B, has the same schema s A as told in the question) satisfies the condition A.ID>40, and hence two tuples are returned. So, number of tuples = 5 + 2 = 7.

The output will be:

edited by
+4

For 50. it should be 5+2 = 7. :)

0
Thanks :) Corrected now.
+1
@Arjun sir..This question and solution both are not clear to me.Can you please explain it
+1

@arjun Sir

A U B

 ID Name Age 12 Arun 60 15 Shreya 24 25 Hari 40 98 Rohith 20 99 Rohith 11

A U B natural Join C => Natural Join is performed using unique ID

 ID Name Age 99 Rohith 11

So only 1 tuple is present in the output .

Where did I went wrong ?

+22
If someone finds it difficult then think like this-

$(R \bowtie _{condition} S) = \sigma_{Condition} (R \times S)$
0
@Arjun Sir,

If I refer the following question GATE 2008-68

R(P,Q,R1,R2,R3)R(P,Q,R1,R2,R3)
S(P,Q,S1,S2)S(P,Q,S1,S2)

For option I
we are treating the join condition as Conditional join implicitly between two entities (R.P = S.P) ^ (R.Q = S.Q) for the symbol ⋈

But in the given question, why we are not treating "A.Id = C.Id" as conditional join implicitly?
Also, as per my knowledge the operator for natural join is *. Please request someone to clarify.
+3

@ AM10

This is theta join: https://en.wikipedia.org/wiki/Relational_algebra#.CE.B8-join_and_equijoin

Also as  Sachin Mittal 1  mentioned above we can think this as a  (RconditionS)=σCondition(R×S)

0

Thankyou Jagmeets. But it is not a  theta join here because there is no condition between attributes (AUB) the new relation formed and the relation C, but having conditional relation with a constant value between them A.Id>40 ∨ C.Id<15. Theta join is applicable when we have conditional join {<, ≤, =, >, ≥} between attributes of entities. Also in the reference article the following line contradicts with the explanation here - "The result of this operation consists of all combinations of tuples in R and S that satisfy θ. The result of the θ-join is defined only if the headers of S and R are disjoint, that is, do not contain a common attribute." But in this question there is an attribute "Id" which seems to be common between the entities (AUB) the newly formed relation and C. But in the question they have not mentioned any relationship among the attribute (fk or pk) I mean, that might be an assumption to consider it as an disjoint set. But it would be great to know views of others.

+5

@ pC

(AB)⋈A.Id>40∨C.Id<15C is theta join not natural join. Theta join is nothing but cartesian product with selection condition, whereas we don't need to specify any selection condition while performing natural join.

0
Can anyone clearly explain to me the join condition given as A.id>40 OR C.id<15? How do I represent it verbally?
0
What is the need of considering AuB schema similar to A , just for A.id=98.

If we are only doing the union between A and B , and finding out the tuples validating the conditions we still get 7 tuples as output.

Plz explain.
SIMPLY WE TRRAT JOIN OPERATOR AS CROSS JOIN on (AUB) cross join C then we have 10 tuples now if we apply cpnstrain on cross join A.id <40 and C.id>45 then we hav three combination

12, 99

15 ,99

25 ,99

if we subtract 3 combination from 10 it will give 7 tuples

now for 2nd ques inner sql give 0 and A.age will be greater tan 0

so, 3 tuples will be selectd