πŸ—οΈ Architecture Star Schema

Dimensions

dim_customer

customer_sk (PK) β”‚ customer_id β”‚ name β”‚ email β”‚ created_at
─────────────────┼─────────────┼──────┼───────┼───────────
[hash]           β”‚ 1           β”‚ Aliceβ”‚ ...   β”‚ 2024-01-01

dim_product

product_sk β”‚ product_id β”‚ product_name β”‚ brand_sk β”‚ category_sk β”‚ price
───────────┼────────────┼──────────────┼──────────┼─────────────┼──────
[hash]     β”‚ 1          β”‚ iPhone 15    β”‚ [hash]   β”‚ [hash]      β”‚ 999.99

dim_date

date_sk β”‚ date       β”‚ year β”‚ month β”‚ day β”‚ dow β”‚ quarter β”‚ week_of_year
────────┼────────────┼──────┼───────┼─────┼─────┼─────────┼──────────────
[hash]  β”‚ 2024-06-01 β”‚ 2024 β”‚ 6     β”‚ 1   β”‚ Sat β”‚ 2       β”‚ 23

Table de Faits

fact_sales

order_id β”‚ date_sk β”‚ customer_sk β”‚ product_sk β”‚ quantity β”‚ unit_price β”‚ subtotal β”‚ year β”‚ month
──────── ┼─────────┼─────────────┼────────────┼──────────┼────────────┼──────────┼──────┼──────
1        β”‚ [hash]  β”‚ [hash]      β”‚ [hash]     β”‚ 2        β”‚ 999.99     β”‚ 1999.98  β”‚ 2024 β”‚ 6

Fluxes de DonnΓ©es

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   SOURCES (Bronze Layer)                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ customers.csv β†’ dim_customer            β”‚
β”‚ brands.csv β†’ dim_brand                  β”‚
β”‚ categories.csv β†’ dim_category           β”‚
β”‚ products.csv β†’ dim_product (+ FKs)      β”‚
β”‚ orders.csv β†’ fact_sales                 β”‚
β”‚ order_items.csv β†’ fact_sales (mesures) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   TRANSFORMATIONS (Silver/Gold Layers)  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1. Load & validate schemas              β”‚
β”‚ 2. Generate surrogate keys (xxhash64)   β”‚
β”‚ 3. Create dimensions                    β”‚
β”‚ 4. Build fact table with joins          β”‚
β”‚ 5. Validate quality (PK, FK, nulls)     β”‚
β”‚ 6. Partition & compress (Parquet)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   OUTPUTS (Gold Layer - Parquet)        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ dim_customer.parquet                    β”‚
β”‚ dim_brand.parquet                       β”‚
β”‚ dim_category.parquet                    β”‚
β”‚ dim_product.parquet                     β”‚
β”‚ dim_date.parquet                        β”‚
β”‚ fact_sales.parquet (year/month)         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Joins

# Fact table construction
fact_sales = (
    order_items             # Base: 100 rows
    .join(products,         # 100 Γ— 20 lookups
          on="product_id")
    .join(orders,           # Preserve order context
          on="order_id")
    .join(customers,        # Add customer dimension
          on="customer_id")
    .join(dim_date,         # Add date dimension
          on="date_sk")
)

Partitionnement

fact_sales/
β”œβ”€β”€ year=2024/
β”‚   β”œβ”€β”€ month=6/
β”‚   β”‚   β”œβ”€β”€ part-00000.parquet
β”‚   β”‚   β”œβ”€β”€ part-00001.parquet
β”‚   β”‚   └── _SUCCESS
β”‚   β”œβ”€β”€ month=7/
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ month=8/
β”‚   β”‚   └── ...
β”‚   └── month=11/
β”‚       └── ...

BΓ©nΓ©fices:

  • βœ… RequΓͺtes par date ultra-rapides
  • βœ… Nettoyage incrΓ©mental (drop partitions)
  • βœ… ParrallΓ©lisation par partition

Voir aussi: DATA_SCHEMA.md pour les dΓ©tails