Start here. This is the direct spoken answer to practice first.
Why this question matters
An API response is not a serialized table graph. The query should produce the bounded client shape directly while keeping row multiplication, permissions, ordering, pagination, and database work explicit.
I start from the response contract and select only the fields needed for the page. For an order list with customer name, item count, and total, I project those scalar values rather than loading complete entities and navigation graphs. Filters, authorization scope, stable ordering, and pagination run in the database. I reason about relationship cardinality before joining: many-to-one data usually joins cleanly, while one-to-many data can multiply parent rows and break both payload size and paging.