Chapter 3 Revision: Query Languages
Database query languages bridge high-level declarative logic and low-level physical disk access. The database engine transforms declarative SQL statements into relational algebra operator trees, optimizes them using heuristic and cost-based models, and executes them against stored relations.
Use these flashcards for active recall. Try to answer the question out loud before clicking the card to flip it.
Flashcards 🎴
What is the critical semantic difference between WHERE and HAVING in SQL?
• HAVING: Filters summarized groups after GROUP BY aggregation has occurred.
How do Inner Join, Left Outer Join, and Full Outer Join behave regarding non-matching rows?
• Left Outer Join: Preserves all tuples from the left relation, padding right-relation attributes with NULLs if no match exists.
• Full Outer Join: Preserves all tuples from both relations, padding unmatched attributes on either side with NULLs.
What is Three-Valued Logic (3VL) in SQL?
val = NULL) evaluate to UNKNOWN rather than TRUE or FALSE (must use IS NULL).What is the difference between a Correlated and an Uncorrelated Subquery?
• Correlated Subquery: References columns from the outer query, logically requiring re-evaluation for every candidate tuple processed by the outer query (unless decorrelated by the optimizer).
What is a Cost-Based Optimizer (CBO) versus a Rule-Based Optimizer (RBO)?
• Cost-Based (CBO): Uses catalog statistics (cardinality, data distribution histograms, I/O cost per page) to calculate estimated execution costs across candidate query trees and choose the cheapest plan.