CoreTrail

Foundations

Understand tables, keys, data types, and how a query is evaluated.

Chapter overviewPostgreSQL2 min read
On this page

Start with what one row means

SQL becomes easier when you can name the input population and required output grain before choosing syntax. This chapter connects tables, keys, types, and logical query order so later joins and windows have a clear foundation.

Suggested route: Read grain and logical query order first, then follow one query through parsing, planning, and execution. Use the practice dataset to predict results before checking the engine.

By the end: Explain why a query returns one row per customer rather than one row per order; distinguish logical SQL order from the physical plan the database actually executes.

Decision reference

Question Construct
Which rows are eligible? FROM, JOIN, WHERE
What is the reporting grain? GROUP BY and aggregates
Which groups qualify? HAVING
Which comparisons retain detail? Window functions
Which rows are displayed first? Final ORDER BY, LIMIT

In this chapter

How to study

Use the suggested route above. For each lesson, explain the decision in your own words, test its example, and identify a situation where a different approach would be needed.

Type a concept, keyword, or function.