Exercise#

In this exercise we will create simple model consisting of 3 tables: customers, orders and traffic (you can already find traffic table as the example.

  1. setup: create core folder within models/marts and _core.yml file.

  2. create table customers: create a table for customers consisting of 3 staging models: stg_jaffle_shop_customers, stg_jaffle_shop_orders and stg_jaffle_shop_orders_value. Create SQL query which will calculate date of first_order and last_order for the customer and their number of orders (no_of_orders) and total amount paid (total_amount) for all orders. Follow the recommended structure while building SQL.

  3. create table orders: create a table for orders consisting of 2 staging models: stg_jaffle_shop_orders and stg_jaffle_shop_orders_value. Include order_id, order_date, customer_id, status, total_amount and coupon_amount columns. All these information were already calculated in staging layer, so there is no need for further calculations.

  4. create table traffic: copy-paste SQL from the provided example into traffic.sql

  5. run dbt run command to create tables

title

Solution#