Introduction
Large enterprise systems evolve over time. New modules are added, integrations change, and migrations happen. With such changes, data inconsistencies gradually appear. Examples include:
A child record exists without a parent (orphan data).
Totals stored for performance become incorrect compared to computed values.
Foreign key references point to deleted or invalid entries.
Duplicate reference relationships appear due to race conditions.
Data sync between microservices or integration pipelines leaves gaps.
Traditional SQL constraints can prevent some mistakes, but many enterprise systems allow soft deletes, asynchronous processing, queued workflows, and multi-system integration pipelines. In such cases, perfect consistency cannot always be enforced in real time.
A Data Auto-Repair Engine solves this problem by continuously scanning the database, detecting inconsistencies, and fixing them safely—either automatically or with human approval.
1. Goals of the System
The objective is to create a controlled, incremental, auditable repair process, not random updates.
Key outcomes:
Identify data mismatches with classification (severity-based).
Provide automated and semi-automated repair actions.
Allow approval workflows before executing fixes.
Track trends to find broken processes, not just broken records.
2. High-Level Architecture
┌──────────────────────────────┐
│ Metadata Catalog │
└─────────────┬────────────────┘
│
┌────────▼────────┐
│ Scanner Job │
└────────┬────────┘
│
┌─────▼─────┐
│ Detector │
└─────┬─────┘
│
┌───────▼────────┐
│ Repair Engine │
└───────┬────────┘
│
┌────────────────▼─────────────────┐
│ Execution Modes: Auto | Manual │
└───────────────┬──────────────────┘
│
┌───────────▼───────────┐
│ Audit + Alert System │
└────────────────────────┘
3. Types of Data Problems Handled
| Category | Example |
|---|---|
| Orphan data | InvoiceLines exists but Invoice deleted |
| Broken FK reference | ProductID refers to non-existing Product |
| Mismatched totals | Header totals differ from line sum |
| Range violations | DateReceived < DateCreated |
| Duplicate business key | Two active customers with same PAN |
| Referential cascades missing | Deleting a contract did not delete children |
Each issue should be assigned a severity level:
| Level | Action |
|---|---|
| Info | Report only |
| Warning | Fix after approval |
| Critical | Auto-fix immediately |
4. Metadata-Driven Rules Engine
Instead of writing rigid SQL scripts, define consistency rules in a rules table.
Example Rule Table

Join the conversation! Your thoughts help the community grow.