The Data Model

The cookbook uses a fictional SaaS company database. All chapters query the same set of tables so you can build on what you’ve learned across chapters.

Entity-Relationship Diagram

Warning: package 'dm' was built under R version 4.4.3
Warning: package 'duckdb' was built under R version 4.4.3

Table overview

Table Rows Purpose
calendar 1,461 Date dimension covering 2022–2025
departments 6 Engineering, Sales, Marketing, Support, HR, Finance
employees 50 Hierarchical via manager_idemployee_id
customers 200 Consumer / Business / Enterprise segments
products 12 Plans, add‑ons, services, features
subscriptions 300 SCD2 style with valid_from / valid_to
orders 800 Completed, pending, cancelled, refunded
order_items ~1,400 1–4 line items per order
support_tickets 400 With priority, category, resolution dates