6,885 views
6 6 votes

Consider the following relational query on the above database:

SELECT S.name FROM Suppliers S 
Where S.sid NOT IN (SELECT C.sid FROM Catalog C
WHERE C.pid NOT IN (SELECT P.pid FROM Parts P WHERE P.color <>'blue'))
  1. Find the names of all suppliers who have supplied non-blue part.
  2. Find the names of all suppliers who have not supplied non-blue part.
  3. Find the names of all suppliers who have supplied only non-blue parts
  4. Find the names of all suppliers who have not supplied only non-blue part.

4 Answers

4 4 votes

Answer : A

Find the names of all suppliers who have supplied non-blue part.

The sub-query “SELECT P.pid FROM Parts P WHERE P.color<> ‘blue’” gives pids of parts which are not blue.

The bigger subquery “SELECT C.sid FROM Catalog C WHERE C.pid NOT IN (SELECT P.pid FROM Parts P WHERE P.color<> ‘blue’)” gives sids of all those suppliers who have supplied blue parts.

The complete query gives the names of all suppliers who have supplied a non-blue part

0 0 votes
Answer will be option A and C both as per ISRO-2015 modified answer keys.
0 0 votes
Take an example:

suppliers                              catalog                               parts

---------------------------------------------------------------------------------------------------------

sid                                     sid    pid                              pid    color

--------------------------------------------------------------------------------------------------------

1                                       1       22                               22    Blue

2                                                                                   23   Red

 

Answer (B)
0 0 votes

Answer in (C) Part.

Explanation -->

Answer:
Position:
Show:

Related questions

3 3 votes
1 1 answer
5.0k
5.0k views
go_editor asked Jun 17, 2016
5,002 views
Consider the following schema:$\textsf{Emp (Empcode, Name, Sex, Salary, Deptt)}$A simple SQL query is executed as follows:SELECT Deptt FROM Emp GROUP by Dept Having avg (...
6 6 votes
3 3 answers
7.6k
7.6k views
go_editor asked Jun 17, 2016
7,568 views
The maximum length of an attribute of type text is$127$$255$$256$It is variable
92 92 votes
8 answers 8 answers
58.1k
58.1k views
gatecse asked Aug 5, 2014
58,146 views
Which of the following statements are TRUE about an SQL query?P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY clauseQ : An SQL query can ...
50 50 votes
3 answers 3 answers
49.9k
49.9k views
Kathleen asked Sep 22, 2014
49,947 views
Increasing the RAM of a computer typically improves performance because:Virtual Memory increasesLarger RAMs are fasterFewer page faults occurFewer segmentation faults occ...