713 views
0 votes
0 votes

Consider the following relational schema and instance R(ABC):

My Answer is 3 because When T1.A = 4 only 1 record will be printed with T2.A = 6 and likewise for when T1.A = 2 only one record will be printed but none for T1.A = 6. Am i right ?

2 Answers

1 votes
1 votes
Answer is 3 tuples but not because of the reasoning your provided.

In the inner related subquery "count *" is returned, i.e., number of tuples that match the condition T1.A < T2.A

If the subquery returns at least one record in its result set, the EXISTS clause will evaluate to true and the EXISTS condition will be met. If the subquery does not return any records, the EXISTS clause will evaluate to false and the EXISTS condition will not be met.

For T1.A=4, count * returns a single record with value 1. Thus row corresponding to A=4 is printed.

For T1.A=2, count * returns a single record with value 2. Thus row corresponding to A=2 is printed.

For T1.A=6, count * returns a single record with NULL. But since it is a record, even if it contains NULL, the EXISTS clause becomes true. Thus row corresponding to A=6 is printed.
0 votes
0 votes
count(*) always provides a number(count) even though it may be 0 or some thing else (1,2,...etc)

 

therefore exists always true for each record..... that implies ans=no.of rows in your instance

Related questions

0 votes
0 votes
1 answer
1
Na462 asked May 12, 2018
404 views
Edges of the directed graph stored in database relation Adj(X, Y) [i.e. if there exists edge from vertex A to B then (A, B) is one record in Adj relation]. Which of the q...
1 votes
1 votes
3 answers
2
aditi19 asked May 18, 2019
1,277 views
Class(name, meets_at, room, fid)Faculty(fid, fname, deptid)Find the names of faculty members who teach in every room in which some class is taught
2 votes
2 votes
2 answers
4
dd asked Dec 17, 2016
2,284 views
Student (Sid,gender,marks,branch)Query: Retrieve Sid's who scored the highest mark?SELECT SID FROM Student EXCEPT SELECT T1.Sid FROM Student T1,Student T2 WHERE T1.marks ...