Chapter 6 of the SQLAlchemy 2 in Practice book walks through building a web traffic analytics solution using SQLAlchemy ORM. It covers designing models for blog articles, authors, users, sessions, and page views, including self-referential relationships for article translations and multi-language support. The chapter demonstrates advanced query techniques including inner vs. outer joins (left, right, full), the CASE construct, table aliases for self-referential queries, SQL UNION to simulate full outer joins across databases, and aggregating page views across original articles and their translations. Practical importer scripts with batched commits for large datasets are also included.
Table of contents
Part 1: Blog Articles and AuthorsPart 2: Blog Sessions and ViewsImporter ScriptsPage Analytics QueriesPart 3: Multi-Language Blog ArticlesLanguage QueriesExercisesSort: