Question 1
In `hr-mini`, `EMPLOYEES.MANAGER_ID` is a self-referencing foreign key: it holds the `EMP_ID` of that employee's manager, and is NULL for employees who report to no one. Which query returns the FIRST_NAME of every employee who is **not** the manager of any other employee — that is, no employee has that person's EMP_ID as their MANAGER_ID?
A. SELECT first_name FROM employees WHERE emp_id NOT IN (SELECT manager_id FROM employees)
Classic NOT IN with a NULL in the value list. Because some MANAGER_ID values are NULL, `emp_id NOT IN (…, NULL)` can never evaluate to TRUE — it is UNKNOWN for every row — so the query returns zero rows instead of the non-managers.
B. SELECT first_name FROM employees e WHERE NOT EXISTS (SELECT 1 FROM employees m WHERE m.manager_id = e.emp_id)Correct answer
NOT EXISTS is evaluated row by row and treats an unmatched correlated subquery as simply 'no matching child'. It correctly keeps every employee whose EMP_ID never appears as another row's MANAGER_ID, and the NULL manager_ids in the subquery do not sabotage it, so it returns exactly the non-managers.
C. SELECT first_name FROM employees WHERE emp_id IN (SELECT manager_id FROM employees)
Inverts the requirement. IN keeps employees whose EMP_ID DOES appear as a MANAGER_ID, so this returns the managers themselves rather than the employees who manage no one.
D. SELECT first_name FROM employees WHERE manager_id IS NULL
Confuses 'is not a manager' with 'has no manager'. MANAGER_ID IS NULL selects employees who report to no one (top of the hierarchy), which is a different set from employees whom no one reports to.
Explanation
Finding rows on one side of a self-referencing foreign key that are never pointed at from the other side is an anti-join, and the safe way to express it is NOT EXISTS (or an outer join with an IS NULL test). NOT IN is a trap whenever the subquery can yield NULL, because a single NULL in the list makes the NOT IN predicate UNKNOWN for every row and the query returns nothing. Selecting on MANAGER_ID directly answers the opposite question — who has no manager — rather than who is nobody's manager.