Skip to content

Referential integrity guide

Dataset Referential Integrity Sampling: Test Parent-Child Evidence Without Exposing Rows

A child row can outlive a parent, point into another snapshot, or be filtered from an export. Use bounded structural samples and explicit orphan states before treating linked datasets as coherent.

A referential-integrity review names the parent key, child reference, expected existence rule, snapshot boundary, and treatment of missing parents. Sample metadata and synthetic identifiers first, preserve orphan evidence as a state rather than deleting it, and distinguish a declared foreign key from an observed export relationship. A clean sample does not prove every row is linked, and an orphan does not by itself establish corruption or unauthorized collection. Source dates shown here are documentation retrieval dates, checked 22 October 2026; original publication dates are not established.

  • PostgreSQL lists foreign keys among table constraints and explains that constraints restrict relationships between rows, which makes the declared parent-child rule part of the evidence packet. PostgreSQL, (opens in a new tab)
  • PostgreSQL notes that constraint behavior depends on the data definition and stored rows, so an exported file still needs an observed, bounded relationship check rather than a name-based assumption. PostgreSQL, (opens in a new tab)

Updated

On this page

Write the parent-child contract

Name the parent table or artifact, the parent key, the child reference, and what “must exist” means at the declared snapshot. A child may reference a parent that is intentionally outside the export, a parent deleted later, or a parent in a different partition. These states are different from a malformed key. Record the expected scope before counting or sampling.

The PostgreSQL, (opens in a new tab) documentation places foreign keys among table constraints, but an exported file may omit the database declaration or the parent table. Treat a constraint definition as evidence of an intended rule and a sampled reference check as evidence about the packet. Do not infer a database constraint from matching column names.

Write the parent-child contract (table)
Contract fieldRecordUnknown if
parent identityartifact, table, and versionParent scope is assumed
parent keyfield path and typeType is inferred from a name
child referencefield path and null ruleNull means are undocumented
existence rulerequired, optional, or conditionalMissing parent disposition is absent
snapshotcapture id and boundaryParent and child were exported separately
exclusionsfilters, partitions, and deletionsExport scope is incomplete

Classify missing parents instead of hiding them

An orphan is an observed child reference with no matching parent in the review scope. It may be a true broken reference, a parent omitted by a filter, a delayed parent export, a deletion or tombstone, a cross-snapshot mismatch, or an invalid key. Keep the raw reference out of a public worksheet, but preserve a stable synthetic or redacted identifier and the reason category.

Link to the key and cardinality guide for uniqueness and duplicate-key evidence. This guide adds scope and snapshot reasoning: a unique child reference is not useful if the parent packet is from another release. A pass should therefore state the sampled population and exclusions.

Classify missing parents instead of hiding them (table)
Observed stateClassify asNext evidence
parent found in same snapshotmatchedretain pair and snapshot id
parent absent, excluded partitionout of scoperecord exclusion rule
parent absent, deletion marker presenttombstoned or deletedlink deletion evidence
parent absent, no explanationorphan unresolvedowner or source investigation
child reference nulloptional or missingapply documented null rule
duplicate parent keyparent identity ambiguoushold dependent checks

Design a bounded sample that can be audited

A useful sample states how parent and child records were selected without exposing their values. Choose a deterministic slice or a synthetic fixture, record the sample frame and exclusions, and retain counts for matched, missing, null, duplicate, and out-of-scope references. Do not describe a sample as representative unless the selection method supports that statement. An unavailable population size should remain unavailable.

Use paired samples when parent and child files have separate capture dates. Compare capture ids, schema versions, and declared filters before comparing references. A percentage computed from an unknown denominator is not evidence. Report counts only for the bounded sample you actually inspected.

Sample fields

  • sample id and selection rule, without raw identifiers
  • parent and child artifact ids and capture boundaries
  • expected reference rule and null policy
  • counts for matched, orphan, duplicate, null, and excluded states
  • unavailable population or coverage fields left explicit
  • reviewer decision and next evidence request

Use synthetic identifiers for the worksheet

Exercise the contract with invented keys that show every state. The fixture below includes a valid pair, a missing parent, an excluded parent, a duplicate parent, and a nullable child. It is a text ledger, not a database query. The point is to make the disposition visible while ensuring that no private row, customer name, or production identifier appears in the public packet.

If a real sample is necessary, use an owner-approved and redacted artifact with a documented audience and deletion path. Keep the raw reference in the controlled system and place only a stable evidence id in the worksheet. Sampling does not grant permission to redistribute the source data.

Use synthetic identifiers for the worksheet (table)
Fixture findingDispositionNext evidence
C1 points to P1 in same snapshotmatchedRetain pair and sample id
C2 points to excluded P9out of scopeConfirm partition boundary
C3 has null referenceconditionalApply nullable rule
C4 points to P2 with duplicate parent keyholdResolve parent identity before sampling
Duplicate parent keyholdResolve parent identity before sampling

Synthetic reference sample

Use synthetic identifiers for the worksheet code example, Plain text
parents: P1, P2, P2
children: C1->P1; C2->P9; C3->(null); C4->P2
scope: P9 excluded from this snapshot
expected: matched=1, null=1, out_of_scope=1, ambiguous_parent=1, unresolved_orphan=0
identity check: parent key P2 intentionally duplicates in fixture

Separate integrity evidence from quality claims

Report “no unresolved references in this bounded sample” rather than “the dataset has referential integrity.” Include the sample rule, source scope, snapshot alignment, and unknowns. An export can pass the sample while missing an entire partition, and an orphan can be explained by a documented deletion workflow. Keep the observation narrow enough to reproduce.

Use the data provenance log for capture and deletion history and the data card for intended scope. Referential integrity says something about relationships, not about semantic accuracy, privacy, rights, value, or demand. Keep those decisions separate.

Separate integrity evidence from quality claims (table)
FindingDispositionDo not infer
Bounded sample has no unresolved referencessample passEvery row is linked
Orphans map to excluded partitionconditional passThe parent is missing
Parent and child snapshots differholdThe references are broken
Duplicate parent keys observedholdThe child chooses one parent
Population or coverage unavailablereport limitationThe sample is representative

Close with a qualified preparation step

After the relationship contract, sample frame, snapshot alignment, and orphan categories are documented, keep the packet at structural evidence level. Do not upload source tables to demonstrate a reference check. A redacted manifest and synthetic keys are enough to test the review contract.

For a supported non-health collection, with authority to describe the linked artifacts and a controlled handling boundary, the qualified appraisal path may be a next preparation step. It does not sample rows, repair links, create a quote, match a buyer, issue a legal opinion, or grant a license. A clean sample is not a permission or accuracy decision.

Takeaways

  • Define the parent-child rule and snapshot before sampling.
  • Keep orphan, null, excluded, deleted, and duplicate states distinct.
  • Use a bounded sample with an explicit denominator and coverage note.
  • Exercise the worksheet with synthetic keys before touching real rows.
  • Report sample evidence narrowly and keep rights and privacy separate.

Sources

  1. PostgreSQL: Constraints: Foreign Keys (opens in a new tab)

Use the appraisal path after the technical packet is organized.

It does not parse files, certify evidence, create a quote, match a buyer, issue a legal opinion, or grant a license.