edited by
970 views
0 votes
0 votes

Consider the following schema:
Suppliers(sid: integer, sname: string, address: string)
Parts(pid: integer, pname: string, color: string)
Catalog(sid: integer, pid: integer, cost: real)
Here key fields are underlined, and the domain of each field is listed after the field name. Therefore sid is the key for Suppliers, pid is the key for Parts, and sid and pid together form the key for Catalog. The Catalog relation lists the prices charged for parts by Suppliers. Consider the table for Part and Catalog given below:

The number of tuples result by given query is  ________.
SELECT C.sid
FROM Parts P, Catalog C
WHERE P.color = ‘red’ AND P.pid = C.pid AND EXISTS (

SELECT P2.pid FROM Parts P2, Catalog C2 

WHERE P2.color = 'green'

AND C2.sid = C.sid AND P2.pid = C2.pid )

 

 

My answer is 3 but given answer is 2 . 

Here i'm not able to understand the flow of query evaluation.  i mean, this is a nested query so which one is outer table and which one is inner? and how the answer is 2.

edited by

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
1
Mrityudoot asked Jan 12
128 views
Isn’t F$^{+}$ minimal cover? If C $\rightarrow$ A is already there, then why does augmented CD $\rightarrow$ A needs to be?
0 votes
0 votes
1 answer
2
1 votes
1 votes
1 answer
3
Sajal Mallick asked Nov 5, 2023
336 views
Unique not null is equivalent to primary key.Relational Algebra and SQL has same expressive power.Which of the above statements are False?
2 votes
2 votes
1 answer
4
kaustubh7 asked Sep 20, 2023
401 views
Consider a relation R having seven attributes ABCDEFG. Fields of R contain only atomic values.FDs = {CD → G, A → BC, B → CF, E → A, F → EG, G → D} is set of f...