Deprecated: Implicit conversion from float-string "1599027206.116" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1599027206.116" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1599027206.116" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1599027206.116" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1599027206.116" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594
Databases: UGC NET CSE | June 2016 | Part 3 | Question: 11
recategorized by
5,443 views
5 votes
5 votes

Consider the following ORACLE relations:

R(A, B, C)={<1, 2, 3>, <1, 2, 0>, <1, 3, 1>, <6, 2, 3>, <1, 4, 2>, <3, 1, 4>}

S(B, C, D)={<2, 3, 7>, <1, 4, 5>, <1, 2, 3>, <2, 3, 4>, <3, 1, 4>}

Consider teh following two SQL queries:

SQ$_1$; SELECT R.B, AVG(S.B) FROM R, S WHERE R.A=S.C AND S.D<7 GROUP BY R.B

SQ$_2$: SELECT DISTINCT S.B, MIN(S-C) FROM S GROUP BY S.B HAVING COUNT (DISTINCT S.D)>1;

If M is the number of tuples returned by SQ$_1$ and If N is the number of tuples returned by SQ$_2$ then

  1. M=4, N=2
  2. M=5, N=3
  3. M=2, N=2
  4. M=3, N=3
recategorized by

4 Answers

6 votes
6 votes

ANS : M = 4 , N =2

output after RxS in SQ1

R.A R.B R.C S.B S.C S.D
1 2 3 3 1 4
1 2 0 3 1 4
1 3 1 3 1 4
1 4 2 3 1 4
3 1 4 2 3 7
3 1 4 2 3 4

 final output of SQ1 :

R.B AVG(S.B)
2 3
3 3
4 3
1 2

SQ2 output :

S.B MIN(S.C)
  1     2
  2     3
2 votes
2 votes

Ans M=5, N=4

SQ1:For 1st query it will select 6 tuples by joining R and S ,where R.A and S.C are equal. Among that 5 are S.D<7

SQ2:Here we are selecting distinct value of S.D>1. In the picture , we can see only one value is not distinct here. So, getting 4 tuples

:

2 votes
2 votes
for SQ2

distinct S.B       count(distinct s.d)

1                              2

2                             2

3                              1

 

but the third tuple is not taken because count(distinct s.d) >1
Answer:

Related questions

2.3k
views
3 answers
3 votes
go_editor asked Aug 20, 2016
2,276 views
Which of the following statements is correct?Aggregation is a strong type of association between two classes with full ownershipAggregation is a strong type of associatio...
4.0k
views
3 answers
1 votes
go_editor asked Aug 17, 2016
4,022 views
Which of the following statements is true?$D_1$: The decomposition of the schema R(A, B, C) into R$_1$(A,B) and R$_2$(A,C) is always lossless$D_2$: The decomposition of t...
5.7k
views
2 answers
3 votes
go_editor asked Aug 17, 2016
5,684 views
Consider the relations $R(A, B)$ and $S(B, C)$ and the following four relational algebra queries over R ans S$\pi_{A, B} (R \bowtie S)$$R \bowtie \pi_B(S)$$R \cap (\pi_A(...
5.8k
views
1 answers
2 votes
Sanjay Sharma asked Jul 11, 2016
5,765 views
In distributed databases, location transparency allows for database users, programmers and administratirs to treat the data as if it is at one location, A SQL query with ...