For our Friday Data Modelling Challenge with Chin & Beards Suds Co. (CBSC), a soap retailer selling products across multiple scents and formats, my partner Luis Vazquez (check out his profile here) and I (check out mine here) was tasked with a real-world data engineering scenario. Our client CBSC needed help setting up their data to answer their key leadership question:

"On a store-by-store basis, are our sales persons reaching their quota?"

The catch was that CBSC's previous data team left not a single piece of documentation. We were handed 17 raw tables sitting in Snowflake with inconsistent data types, unexplained nulls, and questionable summary fields. Our goal was to plan, build, and document a clean, user-ready data model in a single day while leaving behind thorough documentation (in the form of this blog!) so that the next CBSC analyst could hit the ground running.

Step 1: Gathering Requirements & Scoping the Problem

Before writing a single line of SQL, we broke down the business question to figure out what data we actually needed. To know whether certain sales people are hitting their targets by store, we needed four pieces of information:

  • Store details: Which stores exist and where are they located?
  • Sales & employee activity: Who sold what, when, and in what quantity?
  • Product Pricing: What was the price of each product at the time of sale?
  • Quota targets: What sales quota was each sales person expected to hit?

After exploring the 17 tables in Snowflake, we narrowed our scope down to five relevant tables: SALES, SALES_PESON, SALES_PERSON_QUOTA, PRODUCTION_COST, and COST.

Next, we met with our stakeholder to clarify several issues we had with the raw data:

  • Nulls are Online sales: We noticed that rows in SALES, COST and SALES_PERSON_QUOTA where STORE_ID, EMPLOYEE_ID, and EMPLOYEE_NAME were completely NULL, Rather than deleting them, the stakeholder confirmed that these belong to the Online store.
  • Identifying active employees: In SALES_PERSON, the dates ranged up to 29/06/2110, and active employees had 29/06/2110 populated as their END_DATE alongside a NULL ENDDATE_REASON. We confirmed that we should instead filter for active staff using END_DATE = '29/06/2110' rather than relying on ENDDATE_REASON IS NULL.
  • Quota Cycles: Quotas run from April to March. Analyzing the most recent year would evaluate unfinished, in-progress quotas, so we scoped our analysis to the last completed quota cycle (2109-01-04 to 2110-01-04).
  • Revenue and quota definitions: Revenue is calculated as Quantity * RRP using the pre-discount Recommended Retail Price from PRODUCTION_COST (ignoring promotions). Meanwhile, valid target quotas live in SALES_PERSON_QUOTA. The QUOTA column inside SALES_PERSON turned out to be an inaccurate summary field that we needed to drop, along with an empty spreadsheet import column called F9.

Step 2: Mapping the Business Events with a Sun & BEAM Model

With our requirements locked in, we used the 7 W's framework (Who, What, When, Where, Why, How, How many) to build a Sun & BEAM model. Taking 20 minutes to map out the business event before touching Snowflake ensured we didn't miss any necessary keys or metrics:

  • How many: Quota > (Quantity * RRP) tracks whether each salesperson's revenue meets or exceeds their target.
  • Who: Active salespeople (END_DATE = 29/06/2110), captured through Employee_id, Start_Date, and End_Date.
  • Where: Physical store locations, captured via Store_id and Store_location.
  • When: The last completed quota cycle (2109-01-04 to 2110-01-04), captured through Quota_date.
  • What & How: Product Quantity, RRP, and Quota values.
  • Why: Evaluating salesperson performance across stores.

Step 3: Designing the Entity Relationship Diagram (ERD)

Using our Sun & BEAM model as a blueprint, we designed a Star Schema ERD. We placed SALES at the center as our Fact Table because every transaction ties directly to a product, an employee, and a store, while reshaping the remaining tables into clean Dimension Tables (SALES_PERSON, SALES_PERSON_QUOTA, PRODUCT_TABLE derived from PRODUCTION_COST, and STORE derived from COST).

Designing the ERD forced us to solve a critical structural issue: STORE_ID and EMPLOYEE_ID serve as primary and foreign keys, yet they were NULL for all Online transactions and quotas. Leaving keys as NULL violates primary key rules and causes standard joins to silently drop online data. Instead of using numeric placeholders like 0 or 00000 (which could look like real physical store or employee IDs), we decided to standardize NULL keys to 'Online' while leaving EMPLOYEE_NAME as NULL since it is a descriptive attribute rather than a key. We also mapped out cardinalities (such as one Store having many Sales records) and stripped out noisy fields like F9, SALES_PERSON.QUOTA, and PRICE_TABLE.RRP.

Step 4: Cleaning, Joining & Modelling in Snowflake and Tableau

With our plan documented, we moved into Snowflake to build our staging and final tables using the project naming convention (DSNY14_LJ_...).

Phase 1: Cleaning & Standardizing Base Tables in Snowflake

First, we created cleaned versions of our five core tables, fixing data types, defining explicit primary keys to lock in table granularity, and applying COALESCE(..., 'Online') to handle null store and employee IDs.

1. DSNY14_LJ_SALES

We standardized all ID fields to VARCHAR, parsed ORDER_DATE, set (ORDER_ID, PRODUCT_ID) as our composite primary key, and replaced null EMPLOYEE_ID and STORE_ID values with 'Online'.

2. DSNY14_LJ_STORE

We reshaped the COST table into a clean store lookup table by selecting distinct STORE_ID and STORE_LOCATION pairs and applying the same 'Online' coalescing logic.

3.

DSNY14_LJ_SALES_PERSON We validated dates, set (EMPLOYEE_ID, START_DATE) as the primary key, and dropped both F9 and the inaccurate QUOTA summary field.

4. DSNY14_LJ_SALES_PERSON_QUOTA

We standardized data types, set (EMPLOYEE_ID, QUOTA_ID) as the primary key, and replaced null EMPLOYEE_ID values (which represent online store quotas) with 'Online'.

5. DSNY14_LJ_PRODUCT

From PRODUCTION_COST, we kept the product attributes alongside DATE and RRP (dropping production cost columns that were out of scope). Because product prices change over time, we set (PRODUCT_ID, DATE) as the primary key so we could match each sale to the exact price active on that order date.

Phase 2: Joining Tables in Snowflake

Next, we combined our staging tables into three streamlined tables optimized for Tableau:

1. DSNY14_LJ_SALES_FULL

Here we left-joined DSNY14_LJ_STORE to bring in STORE_LOCATION, and used Snowflake's ASOF JOIN against DSNY14_LJ_PRODUCT (MATCH_CONDITION (s.ORDER_DATE >= p.DATE)). Using ASOF JOIN treated our product table like a historical price lookup—automatically attaching the exact RRP valid at the time of each order.

2. DSNY14_LJ_SALES_PERSON_QUOTA_FULL

We left-joined DSNY14_LJ_SALES_PERSON_QUOTA with DSNY14_LJ_SALES_PERSON on QUOTA_ID so each salesperson's target quota sits right alongside their job title, start/end dates, and tenure.

3. DSNY14_LJ_PRODUCT_DIM Finally, even though RRP was already joined onto our sales table, analysts still need a clean lookup table to slice performance by soap name, fragrance, or size without duplicating historical price rows. We created DSNY14_LJ_PRODUCT_DIM using SELECT DISTINCT.

Phase 3: Setting Up Relationships in Tableau

Rather than physically joining transaction-level sales with annual employee quotas in SQL (which would duplicate quota amounts across every order line), we connected Snowflake to Tableau and configured Relationships ("noodles") in the logical layer:

  1. Base Table: Dragged DSNY14_LJ_SALES_FULL onto the Data Source canvas.
  1. Quota Relationship: Related DSNY14_LJ_SALES_PERSON_QUOTA_FULL on Employee Id = Employee Id, setting cardinality to Many-to-Many and referential integrity to Some records match.
  1. Product Dimension Relationship: Related DSNY14_LJ_PRODUCT_DIM on Product Id = Product Id, setting cardinality to Many-to-One and referential integrity to Some records match.

Step 5: Answering the Question & Handover Takeaways

With our model live in Tableau, any stakeholder or analyst can now answer CBSC's business question in four straightforward steps:

  1. Calculate line-item revenue using Quantity * RRP.
  2. Aggregate total revenue at the salesperson level for the completed quota period.
  3. Compare each salesperson's revenue against their assigned Quota using a boolean check (SUM(Revenue) >= Quota).
  4. Break down the view by Store_Location to evaluate store-by-store performance.

Future Considerations for the CBSC Data Team

Because part of our brief was ensuring the next CBSC data hire doesn't start from scratch like we did, we documented four key recommendations for their data team moving forward:

  • Assign 'Online' IDs at the source: Populate an explicit 'Online' identifier for online transactions and quotas at ingestion rather than leaving STORE_ID and EMPLOYEE_ID as NULL (while leaving EMPLOYEE_NAME as NULL since it isn't a key).
  • Standardize active employee end dates: Update HR source records so active staff have a NULL END_DATE (database best practice) instead of the hardcoded 29/06/2110 placeholder. Until that changes, always filter active employees using END_DATE = '2110-06-29' rather than ENDDATE_REASON IS NULL.
  • Filter completed quota cycles: Restrict target attainment reporting to completed April–March quota cycles so active employees aren't flagged as underperforming mid-year.
  • Retire redundant fields & maintain documentation: Drop import artifacts (F9) and inaccurate summary columns (SALES_PERSON.QUOTA and PRICE_TABLE.RRP), enforce VARCHAR/DATE types at ingestion, and keep an updated ERD and data dictionary.

Wrapping Up

Taking 17 undocumented tables and turning them into a documented, stakeholder-ready model in one day reinforced one huge lesson: planning saves hours of rework. Mapping out our requirements, Sun & BEAM model, and ERD before writing SQL made every Snowflake transformation and Tableau relationship intentional—and left CBSC with clear documentation they can actually build on.