SQL & Database Fundamentals: Data Modeling, Queries, and Performance

SQL & Database Fundamentals: Data Modeling, Queries, and Performance

13+

Build a practical SQL foundation by modeling a shop database, writing reliable queries, testing transactions, and reading query plans in PostgreSQL.

0 followers
25 chapters
Software & AI Development
2026
Buying multiple copies? Request bulk pricing.
You're viewing a limited preview. Create a free account to read free books or get Premium to unlock the entire library.

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.

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.

Enjoying this book?

Create a free account to leave comments, track your progress, and more!

Read and listen on the go with the unQbd app. Get the app
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.