SQL checks for synthetic data quality
By the Ground team
Check primary-key uniqueness, foreign-key coverage, row counts, nullability and domain-specific invariants. Use executable SQL against the generated artifact instead of accepting a model's self-reported quality.
Check structural integrity
For each primary key, compare COUNT(*) with COUNT(DISTINCT id) and separately count null IDs. For each required foreign key, use a left join to count missing parents.
SELECT o.id FROM orders o LEFT JOIN customers c ON o.customer_id = c.id WHERE c.id IS NULL;
SELECT id, COUNT(*) FROM orders GROUP BY id HAVING COUNT(*) > 1;
SELECT COUNT(*) FROM orders WHERE id IS NULL;Example request
Validate customers, orders and order_items: zero orphan keys, no duplicate IDs, totals reconcile, and every order date follows the account creation date.
Check semantic integrity
For orders, aggregate line_total_cents by order ID and compare with stored totals. For time series, test that event times are ordered according to the applicable policy.
SELECT o.id, o.total_cents, COALESCE(SUM(i.line_total_cents), 0) AS item_total
FROM orders o LEFT JOIN order_items i ON i.order_id = o.id
GROUP BY o.id, o.total_cents
HAVING o.total_cents <> COALESCE(SUM(i.line_total_cents), 0);Check statistical fit separately
Valid keys do not imply realistic populations. Compare category frequencies, quantiles and relevant cross-column relationships with declared targets or approved reference data.
Common questions
Does zero SQL violations prove realism?
No. It proves only the checked invariants. Evaluate distributions and downstream utility separately.
Try it with your own dataset
Get started, see pricing or use the API.
Review security and privacy when evaluating Ground for your team.