Skip to content
DevTrail

Learn PostgreSQL from Basic to Advanced

Real PostgreSQL in your browser: SQL to performance tuning.

modules
13
topics
63
exercises
249
of practice
41 h 10 min

About this course

Learn relational databases with PostgreSQL: SQL basics, joins, aggregates, constraints and keys, schema design and normalization, indexes and EXPLAIN, transactions and isolation, views, CTEs and window functions, JSONB, functions and triggers, and security. Queries run on real PostgreSQL in your browser (PGlite).

What you'll learn

13 modules and 63 topics. Every topic has short lessons, a quiz, hands-on exercises checked in your browser, and interview questions.

  1. 1Databases and SQL Basics

    What a relational database is, tables, rows, columns and your first queries.

    • What Is a Relational Database?
    • Meet PostgreSQL
    • Your First SELECT Queries
    • Creating Tables
    • Module 1 assessment
  2. 2Querying Data

    SELECT, WHERE, ORDER BY, LIMIT/OFFSET, operators, NULL and pattern matching.

    • Filtering Rows with WHERE
    • Sorting, Paging and DISTINCT
    • Working with NULL
    • Pattern Matching and CASE
    • Module 2 assessment
  3. 3Changing Data

    INSERT, UPDATE, DELETE, RETURNING and upserts.

    • Inserting Rows
    • Updating and Deleting Rows
    • Upserts with ON CONFLICT
    • Module 3 assessment
  4. 4Joins

    Inner, left, right and full joins, self joins and join pitfalls.

    • Inner Joins
    • Outer Joins: LEFT, RIGHT and FULL
    • Self Joins and Multi-Table Joins
    • Join Pitfalls
    • Module 4 assessment
  5. 5Aggregation

    GROUP BY, HAVING, aggregate functions and grouping sets.

    • Aggregate Functions
    • GROUP BY and HAVING
    • FILTER, ROLLUP and Grouping Sets
    • Module 5 assessment
  6. 6Keys and Constraints

    Primary and foreign keys, unique, check, not null and data types.

    • Choosing Data Types
    • Primary Keys and Identity Columns
    • Foreign Keys and ON DELETE
    • NOT NULL, UNIQUE, CHECK and DEFAULT
    • Module 6 assessment
  7. 7Schema Design and Normalization

    Entities and relationships, normal forms, one-to-many and many-to-many design.

    • Entities, Relationships and ER Diagrams
    • One-to-One, One-to-Many and Many-to-Many
    • Normalization: 1NF, 2NF and 3NF
    • When to Denormalize (and Other Design Choices)
    • Module 7 assessment
  8. 8Indexes and Query Performance

    B-tree and other indexes, EXPLAIN and EXPLAIN ANALYZE, and when indexes help.

    • What Indexes Are and How B-trees Work
    • Reading EXPLAIN and EXPLAIN ANALYZE
    • Composite, Partial, Expression and Covering Indexes
    • GIN Indexes and When Indexes Don't Help
    • Module 8 assessment
  9. 9Transactions and Concurrency

    ACID, BEGIN/COMMIT/ROLLBACK, isolation levels, locks and MVCC.

    • ACID and BEGIN / COMMIT / ROLLBACK
    • Savepoints: Partial Rollbacks
    • Isolation Levels and Concurrency Anomalies
    • MVCC, Locks and Deadlocks
    • Module 9 assessment
  10. 10Views, CTEs and Window Functions

    Views, materialized views, CTEs, recursive queries and window functions.

    • Views and Materialized Views
    • CTEs and Recursive Queries
    • Window Functions: Ranking, LAG/LEAD and Running Totals
    • Subqueries vs Joins, EXISTS and LATERAL
    • Module 10 assessment
  11. 11JSONB, Functions and Triggers

    JSONB queries, PL/pgSQL functions, triggers and stored procedures.

    • JSONB: Storing and Querying Documents
    • SQL and PL/pgSQL Functions
    • Triggers: updated_at, Audit Logs and Counters
    • Stored Procedures and CALL
    • Module 11 assessment
  12. 12Security and Operations

    Roles and privileges, row-level security, backups and connection pooling.

    • Roles, GRANT and REVOKE
    • Row-Level Security for Multi-Tenant Apps
    • Backups, VACUUM and Monitoring
    • Connection Pooling and Configuration
    • Module 12 assessment
  13. 13PostgreSQL Projects

    Design and query complete databases for real applications.

    • Project: E-commerce Database
    • Project: Blog Database
    • Project: Library Lending System
    • Project: Hotel Booking System
    • Project: Product Analytics Queries