- Predict the joined row count and sum for the fixture.
- Choose an order-level enrichment strategy and preserve unmatched keys.
- Check distinct orders and source total after the merge.
A join can produce valid output with incorrect totals because the relationship between keys was misunderstood. Use a fictional order and delivery table to predict the output row count before asking AI to write the merge.
Name the expected relationship
The orders fixture contains one row per order, but the delivery table can contain multiple attempts for an order. Joining them directly creates one result per attempt, repeating the order amount. An assistant may call the operation a simple enrichment while overlooking this multiplication. Record whether each key is unique and whether the desired output unit is an order or an attempt. Count key occurrences on both sides before selecting a join method.
Predict a small multiplication by hand
Order O1 has an amount of100cents and two delivery attempts; O2 has200cents and one attempt. The joined amount column sums to400 even though the original orders sum to300. This is not a rounding error. Decide whether to aggregate delivery attempts first, keep an order-level table or explicitly analyze attempts with a separate amount measure. Keep unmatched keys visible because inner joins can silently change the population as well as the row count.
Verify invariants after the merge
Check output row counts, distinct order counts, unmatched keys and the order-level total against the source. A tool reporting merge success only establishes that the code ran. Ask AI for a counterexample with a duplicate key, then verify the expected outcome independently. Document the chosen aggregation and which records it excludes. These checks make the join contract visible and prevent a plausible chart from concealing a many-to-many or one-to-many expansion.
Fictional worked example — Repeated amount
Supplied input
Orders: O1=100, O2=200; attempt counts: O1=2, O2=1
Example result to inspect
Raw join amount sum=400; unique order sum=300
A one-to-many join repeats order attributes; a total must respect the intended observation unit.
This is an authored teaching example, not a recorded live provider run or an independent performance test.
Make the idea concrete.
- Predict the joined row count and sum for the fixture.
- Choose an order-level enrichment strategy and preserve unmatched keys.
- Check distinct orders and source total after the merge.
What a useful outcome looks like
Joining one order to multiple attempts repeats its order-level amount in the result.
Ask for reasoning you can verify.
Use fictional or permitted data. This is a copyable brief for a separate approved model; no model is called from this article.
Help me review this fictional data analysis with ai exercise: Detect row multiplication when combining datasets with nonunique keys. I will supply the original input, my expected result and the actual transformation. Explain cardinality expansion, identify unsupported assumptions about unmatched records, and propose one bounded negative control. Keep observations separate from hypotheses; do not invent output or act on external systems.
Turn reading into a reviewed checkpoint.
Complete the manual exercise, review each item, then answer the evidence question. This records self-study, not independent assessment of expertise.
Review the checklist and pass the question to save this lesson.
Primary references
References support further checking; cited organizations do not endorse AgentX. This guide is original AI-assisted educational content with illustrative examples. Read the editorial policy or report a correction.
Continue with a related task.
Define what one row means
Establish the population, units and collection window before asking AI to analyze a table.
Separate missing, zero and not applicable
Choose missing-value handling from the data meaning instead of a generic cleanup command.
Deduplicate with a defensible identity rule
Distinguish repeated events from duplicated exports before removing rows.