edited by
1,039 views

4 Answers

Best answer
10 votes
10 votes

The relation is put in landscape mode :)

$R = \left\{(1, NULL), (2,1), (3,2), (4,2) \right\}$

Now, a tuple is output if where condition is TRUE. Here the where condition is NOT EXISTS which returns true iff we give empty set to it. So, the condition for output here is that the inner query should not return any tuple.

Based on query, the inner query returns a tuple if the 'A' value being considered exist in any of the tuple as a 'B' value. This happens for A values, 1 and 2 and hence NOT EXISTS is FALSE for these two as the inner query returns $\{(2,1)\}$ and $\{(3,2), (4,2)\}$ respectively. For the tuples $(3,2)$ and $(4,2)$, the inner query returns $\{\}$ and hence they are output. So, the output is $\{(3,2),(4,2)\}$ and answer is 2.

selected by
0 votes
0 votes
There us typo in ques..it should be select * from R1

Now for first 2 tuples inner query returns something so they will not be present in op now for A=3 and A=4 inner query returns empty set..so they will be in op..so 2 tuples are returned..
0 votes
0 votes
comparison with NULL is neither true noe false . its unknown so i think. the result will be unknown.

http://www-cs-students.stanford.edu/~wlam/compsci/sqlnulls
0 votes
0 votes
Only two tuples will be displayed...

The reason behind is that inner query executes for each tuple of outer query so the the tuples selected by inner query is -->

1,NULL

2,1

2,1

so the outer query will display the tuples which are not present in the above..i.e.

3,2

4,2

so the answer is 2 tuples.

click on this link for further clarification --> http://sqlfiddle.com/#!9/e366e/1

Related questions

0 votes
0 votes
1 answer
1
learner_geek asked Nov 29, 2017
516 views
Please explain below query step by step and what does it mean?
0 votes
0 votes
0 answers
2