Sail E0 Webinar
Question

Consider the following relational schema:  

Employee (`underline(empId)`, empName, empDept)

 Customer (`underline(custId)`,custName, salesRepId, rating) 

SalesRepId is a foreign key referring to empId of the employee relation. Assume that each
employee 

makes a sale to at least one customer. What does the following query return? 

 SELECT empName 

 FROM employee E 

WHERE NOT EXISTS (SELECT custId

                                       FROM customer C

                                      WHERE C. salesRepId = E. empId 

                                      AND C. rating < > 'GOOD') 


Options:
A .  Names of all the employees with at least one of their customers having a 'GOOD' rating.
B .  Names of all the employees with at most one of their customers having a 'GOOD' rating
C .  Names of all the employees with none of their customers having a 'GOOD' rating.
D .  Names of all the employees with all their customers having a 'GOOD' rating
Answer: Option D

The outer query will return the value (names of employees) for a tuple in 

relation E, only if
inner 
query for that tuple will return no tuple (usage of NOT 

EXISTS). The inner query  will run for every tuple of outer query. It selects 

cust-id for an employee e, if
rating of customer is NOT
 good. Such an employee

 should not be selected in the output of
outer query.

So the query will return the names of all those employees whose all customers 

have GOOD rating.




Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers