Given the query
SELECT s.rollno FROM student s WHERE s.sex = ALL (SELECT f.sex FROM professor f WHERE f.empid = s.advisor);
which retrieves students whose gender is the same as their advisor's. Consider:
S1. It has a correlated subquery.
S2. It has an uncorrelated subquery.
S3. If we replace ALL by ANY, the result will be different.
S4. If we replace ALL by ANY, the result will be the same.
Identify the TRUE statements:
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: A. S1 and S3 are true
Explanation
The subquery refers to s.advisor, so it is correlated (S1). For a student with no advisor (NULL), the subquery is empty: '= ALL (empty)' is TRUE but '= ANY (empty)' is FALSE, so the results differ (S3).More Database Management Systems questions
- Which of the following queries computes, for each department, the total credits of all the courses offered by the department?
- Which of the following queries retrieves the deptid and name of all departments whose total credits of offered courses is strictly greater…
- Given the query SELECT s.rollno, s.name FROM student s WHERE EXISTS (SELECT c.courseid FROM course c WHERE c.deptno = 5 AND EXISTS (SELECT…
- Identify the incorrect statement.
- Consider the two relations below (primary keys: EMP.eid and DEPT.did). Identify all possible foreign key(s) based only on the two relations…
- Which of the following statements is correct according to the following instance of the relational schema R(X, Y, Z)?X Y Z 1 1 a 1 1 a 2 1…