How do you validate data consistency across multiple databases in an automated test?
Assume synchronized extracts from two databases are available in qa_source_orders and qa_target_orders. Write a SQL query that identifies records missing from either extract or containing different field values.
order_id, source and target values, and consistency_statusorder_id ascendingorder_id, source_customer_email, target_customer_email, source_total_amount, target_total_amount, source_order_status, target_order_status, consistency_status.NULL field values as equal, but treat NULL and 0 as different values.MISSING_IN_SOURCE, MISSING_IN_TARGET, and VALUE_MISMATCH according to the inconsistent condition.| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Order identifier from the source database |
| customer_email | VARCHAR(255) | Customer email recorded in the source database |
| total_amount | DECIMAL(10,2) | Order total recorded in the source database |
| order_status | VARCHAR(30) | Order status recorded in the source database |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Order identifier from the target database |
| customer_email | VARCHAR(255) | Customer email recorded in the target database |
| total_amount | DECIMAL(10,2) | Order total recorded in the target database |
| order_status | VARCHAR(30) | Order status recorded in the target database |