|
1 | 1 | # SQL Data Quality and Behavior Analysis Lab Report: customer_orders_anomalous |
2 | 2 |
|
3 | | -**Report Generated on:** 2026-07-21 15:15:17.616861 |
| 3 | +**Report Generated on:** 2026-07-21 15:17:54.754408 |
4 | 4 | **Source Dataset:** `customer_orders_anomalous.csv` |
5 | | -**Auditor Classification Status:** DANGER / FAIL 🔴 |
| 5 | +**Auditor Classification Status:** CRITICAL ANOMALY DETECTED 🔴 |
6 | 6 |
|
7 | 7 | --- |
8 | 8 |
|
9 | 9 | ## Abstract |
10 | | -This report presents a controlled statistical audit of the SQL database query results comprising 10 samples and 14 features. Using [Multivariate Analysis of Variance (MANOVA)](https://en.wikipedia.org/wiki/Multivariate_analysis_of_variance), [K-Means clustering](https://en.wikipedia.org/wiki/K-means_clustering), and correlation-matrix collinearity tests, we investigate the structure of the retrieved dataset. The objective is to identify potential query design flaws (such as duplicate joins, cross joins, and hardcoded values) and characterize customer order personas. Our findings show that the dataset has a classification status of **DANGER / FAIL 🔴**. We detail actionable recommendations for query optimizations based on detected data anomalies. |
| 10 | +This report presents a controlled statistical audit of the SQL database query results comprising 10 samples and 14 features. Using [Multivariate Analysis of Variance (MANOVA)](https://en.wikipedia.org/wiki/Multivariate_analysis_of_variance), [K-Means clustering](https://en.wikipedia.org/wiki/K-means_clustering), and correlation-matrix collinearity tests, we investigate the structure of the retrieved dataset. The objective is to identify potential query design flaws (such as duplicate joins, cross joins, and hardcoded values) and characterize customer order personas. Our findings show that the dataset has a classification status of **CRITICAL ANOMALY DETECTED 🔴**. We detail actionable recommendations for query optimizations based on detected data anomalies. |
11 | 11 |
|
12 | 12 | ## 1. Introduction and Hypotheses |
13 | 13 | In database engineering and agentic data pipelines, query errors often manifest as subtle statistical anomalies (e.g. artificial correlation due to duplicate joins or zero variance due to cross joins) rather than outright syntax failures. We formally evaluate the following hypotheses: |
@@ -51,22 +51,22 @@ We define a mixed multivariate design incorporating: |
51 | 51 | ## 3. Results |
52 | 52 |
|
53 | 53 | ### Data Quality and SQL Integrity Audits |
54 | | -- **FAIL: Duplicate Join Key in 'O_ORDERKEY'**: Unique rate is 80.00%. Joining on this column will cause a Cartesian product multiplication (row duplication). |
55 | | -- **FAIL: Duplicate Join Key in 'O_CUSTKEY'**: Unique rate is 30.00%. Joining on this column will cause a Cartesian product multiplication (row duplication). |
| 54 | +- **CRITICAL ANOMALY: Duplicate Join Key in 'O_ORDERKEY'**: Unique rate is 80.00%. Joining on this column will cause a Cartesian product multiplication (row duplication). |
| 55 | +- **CRITICAL ANOMALY: Duplicate Join Key in 'O_CUSTKEY'**: Unique rate is 30.00%. Joining on this column will cause a Cartesian product multiplication (row duplication). |
56 | 56 | - **WARNING: Constant Column 'O_ORDERSTATUS'**: 100% of rows contain the value 'O'. |
57 | 57 | - **WARNING: Constant Column 'O_ORDERDATE'**: 100% of rows contain the value '1998-08-01'. |
58 | 58 | - **WARNING: Constant Column 'O_ORDERPRIORITY'**: 100% of rows contain the value '3-MEDIUM'. |
59 | 59 | - **WARNING: Constant Column 'C_MKTSEGMENT'**: 100% of rows contain the value 'AUTOMOBILE'. |
60 | 60 | - **WARNING: Constant Column 'C_ACCTBAL'**: 100% of rows contain the value '5000'. |
61 | 61 | - **WARNING: Constant Column 'AVG_DISCOUNT'**: 100% of rows contain the value '0.05'. |
62 | 62 | - **WARNING: Constant Column 'MAX_SHIP_DELAY'**: 100% of rows contain the value '30'. |
63 | | -- **FAIL: Multicollinearity between 'O_TOTALPRICE' and 'TOTAL_QUANTITY'**: Correlation coefficient is 1.0000. |
64 | | -- **FAIL: Multicollinearity between 'O_TOTALPRICE' and 'TOTAL_DISCOUNT_VALUE'**: Correlation coefficient is 1.0000. |
65 | | -- **FAIL: Multicollinearity between 'TOTAL_QUANTITY' and 'TOTAL_DISCOUNT_VALUE'**: Correlation coefficient is 1.0000. |
66 | | -- **FAIL: ANOVA Replication Anomaly on 'O_TOTALPRICE' by 'C_REGION'**: p-value = 1.000000 (F-statistic = 0.000000). The values are perfectly cloned across categories. |
67 | | -- **FAIL: ANOVA Replication Anomaly on 'TOTAL_QUANTITY' by 'C_REGION'**: p-value = 1.000000 (F-statistic = 0.000000). The values are perfectly cloned across categories. |
68 | | -- **FAIL: ANOVA Replication Anomaly on 'TOTAL_DISCOUNT_VALUE' by 'C_REGION'**: p-value = 1.000000 (F-statistic = 0.000000). The values are perfectly cloned across categories. |
69 | | -- **FAIL: ANOVA Replication Anomaly on 'ITEM_COUNT' by 'C_REGION'**: p-value = 1.000000 (F-statistic = 0.000000). The values are perfectly cloned across categories. |
| 63 | +- **CRITICAL ANOMALY: Multicollinearity between 'O_TOTALPRICE' and 'TOTAL_QUANTITY'**: Correlation coefficient is 1.0000. |
| 64 | +- **CRITICAL ANOMALY: Multicollinearity between 'O_TOTALPRICE' and 'TOTAL_DISCOUNT_VALUE'**: Correlation coefficient is 1.0000. |
| 65 | +- **CRITICAL ANOMALY: Multicollinearity between 'TOTAL_QUANTITY' and 'TOTAL_DISCOUNT_VALUE'**: Correlation coefficient is 1.0000. |
| 66 | +- **CRITICAL ANOMALY: ANOVA Replication Anomaly on 'O_TOTALPRICE' by 'C_REGION'**: p-value = 1.000000 (F-statistic = 0.000000). The values are perfectly cloned across categories. |
| 67 | +- **CRITICAL ANOMALY: ANOVA Replication Anomaly on 'TOTAL_QUANTITY' by 'C_REGION'**: p-value = 1.000000 (F-statistic = 0.000000). The values are perfectly cloned across categories. |
| 68 | +- **CRITICAL ANOMALY: ANOVA Replication Anomaly on 'TOTAL_DISCOUNT_VALUE' by 'C_REGION'**: p-value = 1.000000 (F-statistic = 0.000000). The values are perfectly cloned across categories. |
| 69 | +- **CRITICAL ANOMALY: ANOVA Replication Anomaly on 'ITEM_COUNT' by 'C_REGION'**: p-value = 1.000000 (F-statistic = 0.000000). The values are perfectly cloned across categories. |
70 | 70 |
|
71 | 71 | ### Statistical Hypothesis Testing |
72 | 72 | #### MANOVA Group Factor Outcomes |
@@ -107,17 +107,17 @@ We standardized the numeric metrics and fitted a [K-Means clustering algorithm]( |
107 | 107 |
|
108 | 108 | | Persona Cluster | Order Count | Percentage (%) | |
109 | 109 | |---|---|---| |
110 | | -| **Cluster 1** | 3 | 30.00% | |
111 | | -| **Cluster 2** | 7 | 70.00% | |
| 110 | +| **Cluster 1** | 7 | 70.00% | |
| 111 | +| **Cluster 2** | 3 | 30.00% | |
112 | 112 |
|
113 | 113 |
|
114 | 114 | #### Behavioral Profiles (Cluster Feature Means) |
115 | 115 | To characterize the discovered personas in terms of the original variables, the table below presents the mean value of each numeric metric within each cluster: |
116 | 116 |
|
117 | 117 | | Cluster | O_ORDERKEY | O_CUSTKEY | O_TOTALPRICE | TOTAL_QUANTITY | AVG_DISCOUNT | TOTAL_DISCOUNT_VALUE | ITEM_COUNT | |
118 | 118 | |---|---|---|---|---|---|---|---| |
119 | | -| **Cluster 1** | 3.00 | 29344.00 | 183333.33 | 183.33 | 0.05 | 9166.67 | 9.00 | |
120 | | -| **Cluster 2** | 6.14 | 56903.14 | 107142.86 | 107.14 | 0.05 | 5357.14 | 5.29 | |
| 119 | +| **Cluster 1** | 6.14 | 56903.14 | 107142.86 | 107.14 | 0.05 | 5357.14 | 5.29 | |
| 120 | +| **Cluster 2** | 3.00 | 29344.00 | 183333.33 | 183.33 | 0.05 | 9166.67 | 9.00 | |
121 | 121 |
|
122 | 122 |
|
123 | 123 | ## 4. Exploratory Multivariate Analysis and Cluster Diagnostics |
|
0 commit comments