Data Analysis & SQL5.0 · 0 ratings
Data Quality Audit Query Suite
Generates a battery of SQL checks to surface nulls, duplicates, referential breaks, and anomalies in a table.
Role-BasedFew-ShotStructured-Output
Prompt
ROLE: You are a data quality engineer who writes assertion-style checks before data is trusted. CONTEXT: Audit the table [TABLE_NAME] with schema [SCHEMA]. Business rules it should obey: [BUSINESS_RULES] (e.g., amount >= 0, status in a known set, one row per order). Related tables for referential checks: [RELATED_TABLES]. Engine: [DATABASE_ENGINE]. TASK: 1. Generate checks across these dimensions: completeness (NULLs in required fields), uniqueness (primary key dupes), validity (range/enum/format), consistency (cross-field rules), referential integrity (orphan foreign keys), freshness (max timestamp recency), and volume (row-count anomaly vs prior period). 2. For each check, write a SQL query that returns 0 rows when healthy and the offending rows/counts when not. 3. Assign a severity (block / warn / info) to each check. 4. Recommend which checks belong in CI vs scheduled monitoring. OUTPUT FORMAT: Check catalog table [Check | Dimension | Severity] -> One ```sql``` per check (labeled) -> Where to run each. CONSTRAINTS: Each check must be unambiguous: zero rows = pass. Avoid SELECT *; return only keys and the failing values. Make thresholds parameters, not magic numbers. Note any check that requires a baseline/prior snapshot to evaluate.
Recommended models
claudegpt-4ogemini
More in Data Analysis & SQL
Translate Business Questions Into SQL
Turns a plain-English stakeholder question into a correct, well-commented SQL query against a known schema.
Read prompt
Optimize A Slow SQL Query
Diagnoses why a query is slow and rewrites it with targeted, explained optimizations and an index plan.
Read prompt
Debug A SQL Query That Returns Wrong Results
Systematically finds the logic error producing incorrect numbers and delivers a corrected, verified query.
Read prompt
Explain An Unfamiliar SQL Query In Plain English
Reverse-engineers a complex inherited query into a clear narrative, business meaning, and risk list.
Read prompt