runtime
CRM + ERP Integration · milestone 06 / 12

milestone 6/12 Automated star-schema quality tests

Test relationships and data quality in a star schema.

CRM + ERP Integration · Follow extraction reconciliation, authoritative integration, date quarantine, quality gates, stable keys, replay-safe loads, and atomic promotion. Finish with a customer-grain capstone and field-level lineage.

approach

A quality test has a named expectation and a failure count. Zero means that expectation passed, not that all data is perfect. Check unique line IDs, valid measures, and both dimension relationships. Gate promotion on declared blocking rules; do not silently repair financial data.

worked-example.sql
SELECT 'duplicate_line_ids' AS test,COUNT(*) AS failures
FROM (
  SELECT line_id
  FROM dq_sales
  GROUP BY line_id
  HAVING COUNT(*)>1
)
UNION ALL
SELECT 'orphan_customers',COUNT(*)
FROM dq_sales s
LEFT JOIN dim_customer c ON c.customer_key=s.customer_key
WHERE c.customer_key IS NULL
UNION ALL
SELECT 'orphan_products',COUNT(*)
FROM dq_sales s
LEFT JOIN dim_product p ON p.product_key=s.product_key
WHERE p.product_key IS NULL
UNION ALL
SELECT 'invalid_quantity',COUNT(*)
FROM dq_sales
WHERE quantity IS NULL OR quantity<=0

data for this milestone

dq_sales5 columns · 5 rows
line_idintegercustomer_keyintegerproduct_keyintegerquantityintegersalesreal
111224
29991112
32999180
42300
111224

all 5 rows

dim_customer4 columns · 5 rows
customer_keyinteger · keycustomer_idtextnametextcountrytext
1C001Alice NguyenUnited States
2C002BenUnited Kingdom
3C003CaraUnited Kingdom
4C004DevIndia
5C005ElenaCanada

all 5 rows

dim_product5 columns · 4 rows
product_keyinteger · keyproduct_idtextnametextcategorytextpricereal
1P01NotebookStationery12
2P02Desk lampHome45
3P03KeyboardTech80
4P04HeadphonesTech120

all 4 rows

challenge 1

Return test,failures for duplicate_line_ids (number of duplicated id groups), orphan_customers (rows), orphan_products (rows), and invalid_quantity (NULL or <=0 rows) in dq_sales.

what to return

Columns
testfailures in this order
Rows
any order
challenge-1.sql
 
3 steps left · check both queries and pass the concept checkOpen the reportNext milestone
Automated star-schema quality tests — CRM + ERP Integration · Runtime