Practice
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: Define dependency preservation
It means all FDs can be enforced on decomposed relations without joins.Step 2: Understand relation to lossless join
Dependency preservation does not guarantee lossless join; they are independent properties.Step 3: Evaluate options
If a decomposition is dependency preserving, it must also be lossless join. incorrectly claims dependency preservation implies lossless join.Final Answer:
Option D -> Option DQuick Check:
Options A, B, and D are correct statements about dependency preservation.
- Assuming dependency preservation guarantees lossless join
- Confusing enforcement of dependencies with data loss
- Ignoring performance implications of missing dependency preservation
SELECT category, product_id, total_sales,
RANK() OVER (ORDER BY total_sales DESC) AS rank
FROM (
SELECT category, product_id, SUM(sales_amount) AS total_sales
FROM sales
GROUP BY category, product_id
HAVING SUM(sales_amount) > 200
) sub
ORDER BY category, rank
Solution
Step 1: Examine window function usage
The RANK() function lacks PARTITION BY category, so ranking is global, not per category.Step 2: Understand impact on results
Without partitioning, ranks mix products from all categories, breaking per-category ranking requirement.Final Answer:
Option A -> Option AQuick Check:
Adding PARTITION BY category fixes ranking scope [OK]
- Confusing HAVING and WHERE
- Forgetting partition in window functions
Solution
Step 1: Understand strict 2PL behavior
Strict 2PL holds exclusive locks until commit, which can increase waiting times.Step 2: Analyze deadlock potential
Because locks are held longer, deadlocks can occur more frequently, reducing concurrency.Step 3: Evaluate options
B is incorrect; strict 2PL does not eliminate deadlocks. C is incorrect; locks are not released early. D is wrong; lock compatibility checks are essential. A correctly identifies the trade-off.Final Answer:
Option A -> Option AQuick Check:
Strict 2PL trades off concurrency for serializability, increasing deadlock risk.
- Believing strict 2PL prevents deadlocks
- Thinking locks can be released early in strict 2PL
- Ignoring lock compatibility checks
Solution
Step 1: Analyze query pattern filtering on status and recent dates
Queries filter on status and recent dates, so both columns are used in WHERE clause.Step 2: Evaluate current indexes
Clustered index on date helps range scans; non-clustered on status helps filtering but not combined efficiently.Step 3: Consider composite index benefit
A composite non-clustered index on (status, date) supports filtering by status and ordering by date efficiently.Step 4: Assess other options
Changing clustered index to status loses physical ordering benefits for date range queries; dropping indexes reduces performance; separate indexes cause extra lookups.Final Answer:
Option C -> Option CQuick Check:
Composite index on (status, date) + clustered on date -> best for combined filters [OK]
- Assuming clustered index must be on single most filtered column
- Ignoring composite index advantages
- Believing separate indexes always suffice for multi-column filters
