edited by
29,294 views
70 votes
70 votes

Consider the following relations $A, B$ and $C:$

$$\overset{\text{A}}{\begin{array}{|c|c|c|} \hline \text {ID} & \text {Name} & \text {Age}  \\\hline\text{12}& \text{Arun} & \text{60} \\\hline\text{15}& \text{Shreya} & \text{24} \\\hline\text{99}& \text{Rohit} & \text{11}  \\\hline \end{array}} \qquad
\overset{\text{B}}{\begin{array}{|c|c|c|} \hline \text {ID} & \text {Name} & \text {Age} \\\hline  \text{15}& \text{Shreya} & \text{24} \\\hline\text{25}& \text{Hari} & \text{40} \\\hline\text{98}& \text{Rohit} & \text{20} \\\hline\text{99}& \text{Rohit} & \text{11}  \\\hline \end{array}}\qquad
\overset{\text{C}}{\begin{array}{|c|c|c|} \hline \text {ID} & \text {Phone} & \text {Area} \\\hline  \text{10}& \text{2200} & \text{02} \\\hline\text{99}& \text{2100} & \text{01} \\\hline \end{array}}$$

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$
edited by

6 Answers

0 votes
0 votes

The join mentioned in the query is theta join ( join does the cross product whenever the condition is matched).

Query: $(AUB)\Join _{A.Id>15 VC.Id<15}C$. First we find AUB.

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

Now, if any one of the join condition matches, we do the cross product of tuples where condition becomes TRUE.

For first four tuples of (AUB), A.ID>15 remains FALSE, but C.ID<15 becomes TRUE.

So, First tuple of C appears cross product with first four tuples of (AUB).

And for last two tuples of (AUB) A.ID>15 becomes TRUE, but C.ID<15 remains FALSE.

So, last two tuples of (AUB) are cross product with each of the two tuples of C.

We get the final result as:

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

So, total 7 tuples are in result.

Ans: (A).

0 votes
0 votes

Answer (A)

Result of AUB will be following table

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

The result of given relational algebra expression will be

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

 

Answer:

Related questions

48 votes
48 votes
4 answers
1
go_editor asked Apr 21, 2016
13,737 views
Consider the following relations $A, B$ and $C:$ $$\overset{\textbf{A}}{\begin{array}{|c|c|c|}\hline\\\textbf{Id}& \textbf{Name}& \textbf{Age} \\\hline12& \text{A...
70 votes
70 votes
7 answers
3