Ch. 2
Query Languages for Data
Declarative query languages let you describe what you want; the engine figures out how to get it.
A query language defines how applications read and transform data. Declarative languages like SQL separate the what from the how: you specify the desired result set, and the query optimizer chooses indexes, join order, and execution plan.
Declarative vs Imperative
Imperative code fetches rows and loops in application memory. Declarative queries push work to the database where indexes and statistics enable efficient execution. This separation is why SQL survived decades of hype cycles.
SQLPostgreSQLMongoDBdeclarative queryMapReducequery optimizer