Practice
Solution
Step 1: Understand the problem constraints
We want the second highest distinct salary, so duplicates must be handled and the highest salary excluded.Step 2: Evaluate approaches
Using DISTINCT with ORDER BY and LIMIT OFFSET correctly skips duplicates and the highest salary, ensuring the second distinct highest is returned.Final Answer:
Option B -> Option BQuick Check:
Distinct ordering with offset skips duplicates and highest salary [OK]
- Using MAX() twice returns highest salary again
- ROW_NUMBER() without handling duplicates returns wrong result
Solution
Step 1: Understand AFTER INSERT trigger semantics
AFTER INSERT triggers execute only after the row has been successfully inserted into the table.Step 2: Exclude options contradicting this order
Triggers do not execute before insertion or simultaneously; they also do not execute on failure.Final Answer:
Option C -> Option CQuick Check:
AFTER triggers run post-operation, confirming the insertion occurred.
- Assuming triggers run before the data change
- Believing triggers run on failure
- Confusing BEFORE and AFTER triggers
Solution
Step 1: Understand optimistic concurrency assumptions
Optimistic control assumes conflicts are rare and avoids locking during transaction execution.Step 2: Analyze behavior under high contention
When conflicts are frequent, many transactions abort and retry, reducing throughput.Step 3: Evaluate misconception
Believing optimistic control always improves throughput ignores the cost of retries and aborts in high-contention scenarios.Final Answer:
Option A -> Option AQuick Check:
Optimistic concurrency is beneficial mainly when conflicts are infrequent.
- Assuming no locks means always better performance
- Ignoring the cost of transaction retries
- Confusing optimistic validation with locking
Solution
Step 1: Understand closure computation
Computing the closure of a set of attributes under FDs involves applying Armstrong's Axioms until no new attributes can be added.Step 2: Analyze complexity
While naive enumeration of all subsets is exponential, efficient algorithms compute closure in polynomial time relative to the number of attributes and dependencies by iterative attribute addition.Step 3: Evaluate options
A is incorrect; closure is not always exponential.
B is correct; polynomial time is achievable.
C is incorrect; Armstrong's Axioms are applied iteratively, but recursion stack is not a factor.
D is incorrect; closure computation does not require enumerating all subsets.Final Answer:
Option B -> Option BQuick Check:
Efficient closure algorithms avoid exponential subset enumeration.
- Assuming closure requires checking all attribute subsets
- Confusing recursion depth with iterative inference
- Believing Armstrong's Axioms imply exponential complexity always
Solution
Step 1: Check lossless join condition
Each pair of relations shares a key attribute: R1 and R2 share B (key in R2), R2 and R3 share C (key in R3), so lossless join holds.Step 2: Check dependency preservation
All FDs appear in one of the relations: A -> B in R1, B -> C in R2, C -> D in R3.Step 3: Confirm no FD requires join enforcement
Each FD is enforceable in its own relation, so dependency preservation holds.Final Answer:
Option B -> Option BQuick Check:
Options A, B, and C incorrectly claim loss or preservation failures.
- Assuming chain dependencies require joins to enforce
- Believing lossless join requires all keys in all relations
- Confusing dependency preservation with global key presence
