About This Book
SQL is easier to learn when every query has a purpose and every result can be checked. This book uses one small shop database to connect data modeling, everyday queries, transactions, testing, and performance work. PostgreSQL is the runnable reference throughout. PostgreSQL-specific syntax is labeled, and SQL Server differences appear in separate comparison notes.
Who this book is for
This book is for developers with basic programming experience who want to work confidently with relational data. You do not need prior database experience. If you have written code that stores or retrieves information, you have enough background to begin.
What you will learn and build
You will design and build a shop database with customers, products, orders, and order_items. Starting from business rules, you will choose keys and relationships, create constraints, and load a fixed set of sample data.
You will then write queries that filter, join, aggregate, and analyze that data. Later chapters cover safe data changes, transaction behavior, parameterized Python queries, access restrictions, and repeatable tests. You will inspect PostgreSQL query plans, measure an indexing change without assuming it will be faster, and package schema changes as migrations. The final deployment exercise includes a restore rehearsal.
Each chapter has an exercise and an expected result, so you can check your work before moving on. Diagrams accompany relationships, joins, transactions, and query plans where a visual explanation helps.
How to use this book (recommended reading path)
Read Parts I and II in order. They establish the schema and seed data used by later exercises, and each query chapter builds on earlier results. If you already write SQL, you can move faster through familiar syntax, but run the setup and seed scripts before attempting the project exercises.
Continue through Part III for advanced queries and reliable data changes. Use Part IV when you are ready to test, measure, and prepare database work for deployment. Run examples in a local or disposable database, compare your output with the stated result, and keep your SQL files so you can rerun them after changes.
High-level prerequisites
You need a computer on which you can install PostgreSQL, Visual Studio Code, and a terminal with psql. The book walks you through creating a local development connection. Basic familiarity with files, command-line commands, and programming concepts is enough. The Python client is configured before its examples; Python experience is helpful but not required for the SQL chapters.
