Databases · FOCUSED GUIDE

Learn SQL & PostgreSQL.

Work through joins, transactions, query plans, and relational correctness.

YOUR LEARNING PATH

SQL & PostgreSQL essentials

Start with the essentials or pick the concept you need.

RECOMMENDED NEXTWHERE vs HAVING: what is the difference?
Start learning
01SQL & joinsExplore concepts
  1. WHERE vs HAVING: what is the difference?2 min
  2. What is the difference between the join types?2 min
  3. Why does my join return duplicate rows?2 min
  4. Why does a LEFT JOIN behave like an INNER JOIN?2 min
  5. How should I compare NULL values?2 min
  6. Subquery vs EXISTS vs CTE?2 min
  7. When should I use a recursive CTE or set operation?2 min
02Window functionsExplore concepts
  1. GROUP BY vs a window function?2 min
  2. ROW_NUMBER vs RANK vs DENSE_RANK?2 min
  3. What are LAG, LEAD and running totals?2 min
03Data modelingExplore concepts
  1. What are primary keys, foreign keys and constraints?2 min
  2. What are 1NF, 2NF and 3NF?2 min
04Transactions & lockingExplore concepts
  1. ACID & transaction correctness2 min
  2. What are isolation levels and read anomalies?2 min
  3. Optimistic vs pessimistic locking?2 min
  4. What is a deadlock, and how do I handle it?2 min
05Indexes & optimizationExplore concepts
  1. Which indexes should I know?2 min
  2. EXPLAIN vs EXPLAIN ANALYZE?2 min
  3. Is an index scan always faster than a sequential scan?2 min
  4. What do VACUUM, ANALYZE and autovacuum do?2 min
06PostgreSQL & ORMsExplore concepts
  1. JSON vs JSONB, and views vs materialized views?2 min
  2. What are schemas, roles, sequences, functions and triggers?2 min
  3. What does an ORM do underneath?2 min
  4. How can I practice joins and window functions?2 min

What you will study in SQL & PostgreSQL

Focused lessons organized by concept. Start with the explanation, trace the examples, and check your recall before moving on.

SQL & joins

WHERE filters individual rows before groups are built, while HAVING filters the groups produced by aggregation. They exist at different logical stages of a query. Use WHERE for conditions on source rows and HAVING for conditions such as “the group's total is greater than 1000.”

Window functions

GROUP BY collapses source rows into one row per group, while window functions calculate across related rows without removing the individual rows. A window is defined by partitions, ordering and sometimes a frame. This makes windows useful when a report needs both detail and comparisons such as department rank.

Data modeling

Keys identify records and relationships, while constraints tell the database which stored states are allowed. A primary key identifies each row, a foreign key validates a relationship, and other constraints enforce required or unique values and conditions. Database enforcement protects data even when different application paths write concurrently.

Transactions & locking

ACID describes four properties used to reason about reliable transactions: atomicity, consistency, isolation and durability. Together they address partial changes, preserved rules, concurrent work and persistence after commit. They do not automatically supply correct business rules or the strongest isolation level.

Indexes & optimization

An index is a separately maintained structure that makes suitable lookups, joins or ordering operations cheaper. B-tree is a common general-purpose choice, while composite, partial and unique indexes describe field arrangement, row selection and data rules. An index helps only when the planner estimates its use is worthwhile for the query and data.

PostgreSQL & ORMs

JSON stores JSON input text, while JSONB stores a processed representation that supports efficient operations and indexing. A view stores a query definition, whereas a materialized view stores the query's result for later reads. These are separate choices about data representation and precomputed results.

Related to SQL & PostgreSQL
Expand your skills next