Data & analysisData joinstext

Join tables without inflating counts

Designs a safe join and cardinality audit.

Editorial illustration for Join tables without inflating counts
Editorial illustration for this prompt; the prompt itself does not generate this image.

Ready to use

Prompt

Given schemas and sample rows for [TABLE A] and [TABLE B], identify join keys, expected cardinality and null behaviour before proposing a query. If full-table counts are supplied, calculate before/after row totals; with schemas and sample rows alone, give cardinality bounds and unrun validation queries rather than exact production totals. Explain what duplicates would mean and give three assertions to detect inflation. Provide SQL or pseudocode for [DATABASE], plus a reconciliation table for unmatched and multiply matched records. Do not guess that similarly named columns share the same meaning. Return a short explanation of which aggregate is safe to publish only after the assertions pass.