How Can We Combine Records Without Losing or Multiplying Their Meaning? Define what one row represents in each register, join records using a stated key, and check how many matches each record produces. A correct join can legitimately produce more rows than either starting table. The danger is interpreting those new rows as if they still represented the original objects. This lab teaches learners to predict and audit the result before summarising it.
This international coursework uses fictional exhibit inventories and inspection logs. It extends the Correlation and Pairing Lab from preserving existing pairs to constructing new pairs under a rule. AI can propose queries, but learners verify their meaning with small hand-worked registers. The activities and rubric are proposed coursework, not validated interventions; future superintelligence remains hypothetical.
- Identify the unit represented by a row, and distinguish keys from descriptions.
- Predict inner, left and full outer join results.
- Calculate output cardinality from the number of matching rows.
- Keep unmatched records visible without treating unknown values as zeros.
- Avoid counting an inventory quantity multiple times after a one-to-many join.
- Audit changes to filters, duplicate keys and fresh transfer cases.
Choose your reading route
Coursework series: Correlation and Pairing Lab · Data Quality Lab · Aggregation and Weighting Lab · Interface Contract Studio · Vocabulary Coding and Engineering
Continue this coursework series: Residual and Model Fit Lab · Logarithmic Scale Lab · Data Join and Cardinality Lab (this article) · Contrast and Concession Studio
Full chapter index
Chapters 1–5
Chapters 6–10
Chapters 11–15
Chapters 16–20
Chapters 21–25
Chapter 26
1. The capability: join information without confusing its units
Two useful datasets may describe different aspects of the same activity. A catalogue describes exhibits; an inspection log describes individual inspection events. Joining them can show which events belong to which exhibit, but the resulting rows may no longer represent a list of unique exhibits. Ask the learner to define the unit of observation before and after joining.
The coursework artifacts are two input registers, an explicit matching rule, a joined table, a row-count reconciliation and a separately checked summary. A generated database query is only one possible implementation. Learners can demonstrate the same reasoning on paper by matching record cards and checking the counts.
2. Define the operation and key
A join combines rows according to a condition. In this lab it compares the exhibit identifier in one register with the exhibit identifier in another. PostgreSQL’s join tutorial introduces matching rows and outer joins; PostgreSQL’s table-expression documentation describes how different join types handle rows that have no match.
A primary key identifies each row uniquely within a table and cannot be null. In our catalogue, the exhibit identifier is unique. In the log, the event identifier is unique, but the exhibit identifier can occur repeatedly because one exhibit can have several events. We deliberately allow an unmatched identifier in the toy log; a properly enforced foreign-key constraint to the catalogue would prevent that particular orphan.
3. Vocabulary Coding and Engineering for record linkage
Within eduKate’s proposed Vocabulary Coding and Engineering framework, define row, entity, event, key, matching condition, cardinality and missing value before manipulating records. An entity may have several events. Cardinality in this lab means the count of output rows or the number of permitted matches in a relationship, with the intended sense stated each time.
Make a small ledger of what each phrase allows. Count of joined rows does not necessarily mean count of exhibits. An unmatched record does not mean that an exhibit was inspected and failed. Precise vocabulary helps learners inspect AI-produced queries and summaries, rather than accepting a familiar label with a changed meaning.
4. The original fictional exhibit registers
The catalogue contains exactly four records: E1 with six pieces, E2 with four, E3 with eight and E4 with two. Piece counts are properties of exhibits, not inspections. The inspection log contains four distinct events: I1 for E1, ready, three minutes; I2 for E1, review, five minutes; I3 for E2, review, seven minutes; and I4 for E9, ready, eleven minutes.
The log intentionally contains an unmatched exhibit identifier E9. This is a simulated reconciliation task, not an example of a database with an enforced foreign key. Join on equality of the exhibit identifier. Preserve the event identifiers because I1 and I2 are separate recorded events even though they concern the same exhibit. The tables below contain the entire fictional dataset.
| Catalogue exhibit | Pieces |
|---|---|
| E1 | 6 |
| E2 | 4 |
| E3 | 8 |
| E4 | 2 |
| Event | Exhibit ID | Status | Minutes |
|---|---|---|---|
| I1 | E1 | ready | 3 |
| I2 | E1 | review | 5 |
| I3 | E2 | review | 7 |
| I4 | E9 | ready | 11 |
5. Predict matches without executing a query
For E1, there are two log events, I1 and I2. For E2, there is one event, I3. E3 and E4 have none in this supplied log. Event I4 belongs to E9, which has no matching catalogue row. Draw a line from each catalogue card to every log card with the same exhibit identifier.
Use the match counts 2, 1, 0 and 0 to predict the joined output before running a program. The absence of a match indicates absence from this particular register under the defined condition. It does not prove the exhibit has never been inspected outside the supplied dataset.
6. Calculate the inner join
An inner join returns a row for each matching pair. The output therefore contains (E1,I1), (E1,I2) and (E2,I3). The output has three rows, not three unique exhibits. Two unique catalogue identifiers appear. E3, E4 and event I4 do not appear because they have no matching partner.
In SQL-like notation the condition is Catalogue.exhibit_id = Log.exhibit_id, with an inner join. A learner can reproduce these three pairs by hand before comparing them with a generated query. Sorting the output changes presentation, not which pairs satisfy the condition. Without an explicit order requirement, do not assume a database returns rows in a particular order.
7. Calculate the left outer join
A left join from the catalogue retains all matching pairs and adds a row for each catalogue record with no match, using missing right-side fields. The result includes the three inner-join rows plus E3 with no event and E4 with no event, giving five rows. The left-side identifiers remain available for all four exhibits.
The table records missing log fields as NULL, not as a fictitious event. E1 still occurs twice. Retaining all left entities is different from guaranteeing exactly one output row per left entity. That distinction is the central inspection check for a learner who wants to create a summary with one row per exhibit.
| Catalogue exhibit | Pieces | Event | Minutes |
|---|---|---|---|
| E1 | 6 | I1 | 3 |
| E1 | 6 | I2 | 5 |
| E2 | 4 | I3 | 7 |
| E3 | 8 | NULL | NULL |
| E4 | 2 | NULL | NULL |
8. Calculate the full outer join
A full outer join retains unmatched records from both sides. It includes the five left-join rows plus event I4 with missing catalogue fields. There are six joined rows in total: three matched pairs, two unmatched catalogue records and one unmatched log record.
If both identifier columns are retained, the final row has catalogue identifier NULL and log identifier E9. A reporting layer can display a combined identifier if it explains the rule for selecting the nonmissing value. It should still preserve the fact that E9 had no catalogue match. Do not label the missing catalogue piece count as zero.
9. Generalise the match-count calculation
For a nonmissing key k, let c(k) be the number of catalogue rows with that key and l(k) the number of log rows with that key. Under equality matching with no other filters, that key contributes c(k) × l(k) rows to an inner join. Add these products across keys. Each matching pair is represented once in this model.
For the original data, E1 contributes 1 × 2 = 2, E2 contributes 1 × 1 = 1, and all other keys contribute zero. With a left join, each unmatched left row contributes one padded row instead. Thus 2 + 1 + 1 + 1 = 5. Use this calculation to detect accidental many-to-many matching before analysing larger tables.
10. Recognise the duplicated quantity trap
The catalogue’s total piece count is 6 + 4 + 8 + 2 = 20. In the left-joined table, the E1 quantity six occurs on both I1 and I2 rows. Adding the repeated piece-count field directly gives 6 + 6 + 4 + 8 + 2 = 26. The arithmetic is correct for those five rows, but it is not the total number of catalogue pieces.
Repair the analysis by calculating the catalogue total at catalogue grain, meaning one row per exhibit, or by carefully rebuilding one row per exhibit after the join. Do not simply sum distinct numerical piece counts: two different exhibits could legitimately each contain six pieces. Uniqueness belongs to the exhibit identifier, not to the quantity value.
11. Aggregate events before combining entity totals
For matching catalogue exhibits, the log minutes are eight for E1, seven for E2, and no logged events for E3 or E4. The matched-event total is fifteen minutes. The entire log contains twenty-six minutes, including eleven from the unmatched event I4. These totals answer different questions.
An exhibit-level summary can first group the log by exhibit identifier and calculate event count and total recorded minutes. After a left join, use a clearly defined zero for the count of matched events when no event rows exist. For total minutes, zero may represent the sum over an empty set of recorded events under the exercise’s convention, but it does not establish actual time spent outside the register.
12. Do not confuse NULL with a recorded zero
The left-joined row for E3 has no event identifier and no event duration. A duration of zero, by contrast, could be a genuine recorded value under a suitable measurement rule. Replacing both with zero without a status flag would erase that distinction. Learners should label the source of any imputed value.
For this particular join, counting all output rows gives five, whereas counting non-null event identifiers gives three. Counting distinct non-null catalogue identifiers gives four. These are different counts even though they come from the same table. State which column and which count rule the summary uses.
13. Check how a duplicate left key changes the output
Consider a defective alternate catalogue that repeats E1 on a second row, with the same six pieces. If those duplicate rows are both admitted, the two E1 catalogue rows each match two E1 events. The key contributes four inner-join rows, not two. The inner output now has five rows and the left output seven.
The duplication violates the stipulated unique identifier rule. Do not choose one row silently if the duplicates disagree. Quarantine the conflict, retain the source records, and ask which is authoritative before rebuilding the catalogue. The exercise illustrates why a technically successful join can still be unacceptable when its inputs violate the data contract.
14. Move a filter and inspect the difference
Suppose the question is to retain every catalogue exhibit and show any ready events. Put the ready condition into the matching rule of a left join. E1 matches I1 only. E2, E3 and E4 have no ready match and each receives a padded row. The resulting table has four rows.
Alternatively, perform the original left join and then filter the result to rows whose log status equals ready. Only (E1,I1) remains: the review rows fail the filter and NULL status does not satisfy equality to ready. The two operations are not equivalent. PostgreSQL’s table-expression documentation explains the distinction between join conditions and later row filtering; learners should identify which operation answers the intended question.
15. Check whether an identifier is the right matching key
Imagine a later log covering two exhibitions that both use the label E1. Matching by exhibit identifier alone could join an event to the wrong exhibition. If identifiers are only unique within an exhibition, a composite key such as exhibition_id together with exhibit_id is necessary to represent the intended relationship.
Before changing the join, ask how identifiers are issued and what uniquely identifies an entity. Do not silently infer that two equal display names represent the same object. Similar names and inconsistent spelling can make the correct identity unresolved. A reconciliation report should keep unresolved cases visible rather than guessing a match.
16. State missing information and data boundaries
The classroom tables contain four inventory rows and four log rows, with complete values in those rows. They do not model simultaneous edits, uncertain identifiers, historical revisions or permissions. In an actual project, those conditions require explicit rules and source access controls before integration.
Use only fictional or appropriately authorised data in learner exercises. Do not send personal records to an AI service just to demonstrate a join. A small simulated register supports the same reasoning. If using a database, check its treatment of NULL, duplicates and matching conditions; the mathematical row-count exercise assumes the stated equality rule.
17. Use AI to produce a checkable join explanation
Ask an assistant to list every match for each exhibit and calculate the expected row count before suggesting SQL. It should retain both key columns for unmatched rows and distinguish original quantities from event fields. Compare its output with the hand-matched cards.
Request one deliberately broken analysis: for example, a sum of the piece-count column after a left join. Identify the duplicated E1 quantity and calculate the correct catalogue total separately. Preserve the erroneous claim and repair with the original data so the learner can demonstrate exactly what went wrong.
18. A prompt for row meaning and reconciliation
Try: Given the four exhibit rows and four log events from the lab, join on equal exhibit identifiers. Provide inner, left and full outer results with both identifiers, explain every unmatched row, and reconcile all output counts. Keep NULL distinct from zero. Calculate catalogue pieces and matched-event minutes at the appropriate grain.
Next ask for the output of a left join with a ready condition in the match, then compare it with filtering status after the join. Require a row-by-row explanation. The learner should verify those differences independently and reject a query that happens to produce a plausible total for the wrong question.
19. A proposed assessment rubric
Score four dimensions from zero to three: explicit row units and key contract; complete match register and cardinality; correct aggregation and missing-value interpretation; independent transfer with a filter or duplication check. Zero means absent relevant evidence, one partial work with major errors, two mostly correct reasoning with a specific gap, and three complete reproducible work.
Keep the four dimensions visible rather than relying on a total out of twelve alone. This original rubric is an instructional proposal, not a validated measure of data-literacy proficiency. Accept card matching, a written table or a spoken explanation when it makes the reasoning inspectable, with agreed accessibility supports.
20. Independent transfer: join a fresh collection and check its totals
A second fictional catalogue lists A with five items, B with seven, and C with nine. Its event log contains J1 for A, two minutes; J2 for A, four minutes; J3 for B, six minutes; and J4 for D, eight minutes. Predict inner, left and full outer counts, the catalogue item total, and the matched-event total. Then check whether summing item quantities after the left join preserves the original total.
Worked check: inner rows are (A,J1), (A,J2), (B,J3), giving three. The left join adds C with no event, giving four. The full join adds D’s unmatched J4, giving five. Catalogue items total 21; the left-joined quantity sum is 26. Matched-event minutes total 12, while all log minutes total 20. Explain why the two totals have different scopes and why five full-join rows do not establish five catalogue objects.
21. Primary learning: match object cards and event cards
Use cards for a few fictional boxes and separate cards for visits to those boxes. Give one box two visit cards and another none. Children can make matching pairs, count boxes and count visits separately. Ask why a box appears twice in the paired list even though it is still one box.
Use large print, tactile labels or spoken identifiers and keep the numbers manageable. The goal is preserving identity and counting the intended thing, not teaching database syntax prematurely. Adults may prepare checked examples with AI without requiring a child to use an AI service.
22. Secondary learning: connect tables and matching rules
Students can construct the three join results and derive the count formula for the small register. Ask them to explain what a missing event means and to identify a double-counted entity quantity. Then show the ready-filter contrast and have them predict the result before running any program.
Where coding is appropriate, learners may translate the match rules into a database query using official documentation. Retain the original rows and the expected outputs beside the query. A correct program is stronger coursework when another learner can explain the underlying data contract without relying on that program.
23. University, institutions and EnDist
Advanced work can study relational algebra, integrity constraints, data lineage and cardinality estimation. Real integrations require careful treatment of entity identity, temporal validity, privacy and permissions. Do not apply the simple classroom result to sensitive operational data without an appropriate design and review process.
Within eduKate’s proposed EnDist framework, AI could distribute the ability to combine datasets across more participants. Education should also distribute the ability to preserve what each record represents and verify any new linkage. Shared key definitions, reconciliation counts and documented exceptions help different teams challenge an apparently coherent merged result.
24. A four-week Data Join and Cardinality Lab
Week one defines the two registers, matches cards and builds inner and left outputs. Week two adds the full join, derives the cardinality calculation and compares entity totals with event totals. Deliver the input records, join condition and reconciliation together.
Week three examines duplicate keys, NULL and filter placement, then repairs a generated query explanation. Week four completes the independent transfer and uses the rubric to identify a specific improvement. Adapt the pace and use small fictional datasets throughout; the sequence is a proposed classroom design.
25. Questions about joins and counts
Does an inner join keep all original rows? No; only matched pairs are retained. Does a left join give exactly one row per left record? Not necessarily; a left record with several matches produces several rows. Does an unmatched record prove there are no events in reality? No; it describes what is absent from the joined source.
Can a valid join give a wrong summary? Yes, if the analyst aggregates at the wrong grain. Should a duplicate key always be deleted? No; resolve the conflict according to the data contract and source evidence. Can AI help? It can generate queries and match registers, while learners verify the intended row unit and the resulting counts.
26. Sources, boundaries and next steps
The technical background is supported by PostgreSQL’s join tutorial and PostgreSQL’s table-expression documentation. The fictional catalogue, logs, deliberately defective variants, worked transfer and rubric are original classroom constructions. They do not report observed institutional data or measured learning outcomes.
Continue by building two small registers with a shared key, deliberately including one repeated match and one unmatched row on each side. Predict the output count before joining and explain which quantities can safely be aggregated afterward. The capability is not merely combining information; it is preserving the meaning of the information after combination.
Related coursework: Correlation and Pairing Lab · Data Quality Lab · Aggregation and Weighting Lab · Interface Contract Studio.