Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
FREEDOM251

Freedom251 › Blog › data generation

How to Fix Synthetic Data That Fails to Preserve Relationships Between Tables

By Freedom251 Team · · 6 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fixing broken relationships starts with identifying which of two problems you have: orphaned foreign keys, where a child row points to no existing parent, or implausible relationships, where keys resolve but the parent-child patterns no longer resemble the rules and distributions your application needs. Check the source data and relationship metadata, use a generation strategy that accounts for connected tables, then validate key integrity and relationship quality separately before using the output.

Why do synthetic foreign keys become orphaned?

A foreign key can be generated as an ordinary-looking value without being selected from the generated parent table. That is likely when tables are synthesized independently: the child-table process may not know which parent keys were sampled. A basic multi-table generator can have the same limitation. SDGym documents that its MultiTableUniformSynthesizer randomly generates ID columns and does not ensure valid connections or referential integrity.

As an Amazon Associate I earn from qualifying purchases.

There is a second, less obvious failure: every foreign key may resolve, but the relationships can still be wrong for your use. For example, a child row may point to a valid parent of an incompatible category, or the number of children per parent may be implausible. A successful join proves that keys match; it does not prove that the connected data is useful or realistic.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Separate the checks

  • Referential integrity: Does each non-null child foreign key occur in the corresponding parent primary-key column?
  • Relationship structure: Does the generator have accurate table, key, and relationship metadata?
  • Relationship behavior: Do child counts, bridge-table patterns, and parent-child combinations meet the intended rules?

SDMetrics’ multi-table metadata guidance describes metadata as the schema information that identifies tables and their primary- and foreign-key relationships. Its diagnostic documentation includes measures beyond key resolution, such as cardinality checks.

How do I diagnose the relationship failure?

Check the generated keys directly

For each child-to-parent relationship, compare non-null foreign-key values in the generated child table with primary-key values in the generated parent table. Count unmatched values and retain a few example rows so you can trace the issue back to generation or mapping logic. Also check that parent keys are unique; duplicate keys make a relationship ambiguous even if a basic join returns rows.

Decide what null means for each foreign key. SDMetrics’ ReferentialIntegrity metric checks the proportion of synthetic foreign-key values found in the synthetic primary-key column, but treats missing foreign-key values as valid. If your relationship is mandatory, run a separate null check rather than letting nulls inflate the apparent success of the integrity check.

Check whether the metadata describes the real schema

Compare the metadata consumed by the generator with the database schema. Confirm table and column names, key columns, key data types, primary-key uniqueness, and each foreign-key mapping. A wrong type, omitted relationship, or incorrect mapping can cause a model to generate tables as if they were unrelated. Also confirm whether the relationship is one-to-many or many-to-many and whether a bridge table has its own uniqueness rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

SDMetrics’ Multi Table Metadata guide describes multi-table metadata in terms of tables and key relationships. SDV’s database connector documentation explains that database schemas provide column names, types, and table connections used to create metadata. That ingestion path uses SDV AI Connectors, an Enterprise feature; availability depends on your SDV edition.

Profile the real input before changing rules

Inspect the source tables for duplicate parent keys, orphan child keys, null keys, inconsistent key types, and bridge-table duplicates. Then compare observed child counts and parent-child combinations with the assumptions you intended the synthetic data to follow. If the source already contains exceptions, decide whether those are errors to clean or legitimate cases your synthetic data should retain.

How do I preserve relationships when generating the data?

Prefer a relational generator when tables must be modeled together

Use a multi-table synthesizer that consumes relationship metadata and supports the constraints your schema requires. SDV documents multi-table relational generation, evaluation, and constraints. That is a documented capability, not proof that it will outperform every alternative or preserve every pattern in every schema. Validate its output against your own acceptance criteria.

SDV’s Constraint Augmented Generation documentation lists multi-table constraint types such as ForeignToPrimaryKeySubset, CompositeKey, and UniqueBridgeTable. CAG is described as an SDV Enterprise bundle, so check your installed version and licensing before planning around those features.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make dependencies explicit in a custom pipeline

If separate generators are necessary, make parent keys available before assigning child foreign keys. Generate or establish the parent key set first, then choose child references from that set. Separately model child counts and conditional values—for example, which parent categories can have which kinds of children. This staged approach is an engineering fallback, not a guarantee that higher-order relationships will be preserved; validate the resulting data.

Do not assume that independently generated ID columns establish relationships. A key is only a valid reference when it matches a key in the intended parent table, and a valid match alone does not encode a realistic association.

Compare approaches against your requirements

Approach Relationship handling What to verify
Relational or multi-table synthesizer Uses table relationships and may support relationship constraints; exact behavior depends on the product, configuration, and version. Whether the required key, bridge-table, conditional, and cardinality rules are supported, and whether output passes your tests.
Custom staged pipeline Generates parents first, then assigns child references under explicit rules. Whether key assignment, child-count distributions, and conditional relationships remain plausible at your scale.
Independent or basic ID generation May generate identifiers without valid cross-table links. SDGym documents this limitation for MultiTableUniformSynthesizer. Do not treat generated IDs as proof of valid references; measure integrity and relationship behavior after generation.

Choose based on schema complexity, scale, integration needs, supported constraints, and the fidelity your downstream work requires. No single approach is established as a universal fix.

When should I add constraints or clean the source data?

Use deterministic constraints only for rules that are genuinely true of the input you intend to model. SDV’s troubleshooting documentation states: “A constraint should describe a rule that is true for every row in your real data.” If an input row violates a configured constraint, SDV reports a ConstraintsNotMetError.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When violations are legitimate source exceptions, removing those rows solely to satisfy the constraint can make the synthetic data less representative of the original input. Decide whether to remove the constraint, correct invalid source records, or revise the rule to account for valid exceptions. Document the choice so future runs do not silently change what the data represents.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How do I validate referential integrity in synthetic data?

Run validation after sampling and before loading, sharing, or using the dataset. Treat the checks below as separate gates: passing one does not imply the others pass.

  1. Validate key uniqueness. Confirm each generated primary key is unique in its table. Check composite keys using the full key combination when applicable.
  2. Validate reference resolution. For each foreign key, count non-null values that do not occur in the mapped parent primary-key set. Use SDMetrics ReferentialIntegrity if it fits your workflow, and add a separate null check for mandatory relationships because that metric treats missing foreign keys as valid.
  3. Validate relationship counts. Compare child rows per parent with plausible bounds and business expectations. SDMetrics Diagnostic includes CardinalityBoundaryAdherence, a connection diagnostic for this kind of assessment.
  4. Validate bridge tables and business rules. Check composite-key uniqueness, duplicate associations, allowed parent-child combinations, and any conditional rules required by downstream joins or tests. SDV CAG documents constraints including CompositeKey and UniqueBridgeTable.
  5. Validate structure separately. Compare generated table and column structure with the expected schema. SDMetrics Diagnostic includes table-structure measurements; structural validity is distinct from referential integrity.

Keep a small report for each output batch with failure counts and example records. If you repair references, use a deterministic, auditable mapping and re-check the affected relationship distributions. Replacing every orphan with an arbitrary valid parent key can make the integrity check pass while assigning the child to the wrong parent.

How do I tell whether the relationships are realistic—and whether the data is safe?

Once references resolve, assess the patterns that matter to the intended use: child counts per parent, cross-table conditional structure, bridge-table frequencies, and relevant domain rules. Set acceptance criteria around how the data will be consumed. A database load that succeeds demonstrates compatibility with a schema, not statistical utility.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Assess privacy separately from relationship quality. SDMetrics’ single-table detection guidance says not to apply detection metrics to primary- or foreign-key ID columns. It also cautions that a perfect detection score could indicate copied data and possible privacy leakage. A good integrity score therefore says nothing by itself about privacy, and a detection score is not a substitute for relationship checks or a broader privacy assessment.

What a reliable fix looks like

A reliable repair addresses the cause rather than just suppressing the symptom: accurate metadata, a generator or pipeline that respects parent-child dependencies, constraints grounded in the real input, and batch validation for uniqueness, references, cardinality, and business rules. Keep relationship validity, behavioral realism, schema compatibility, and privacy as distinct acceptance questions.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

data generationreferential integrityrelational databasesSDVsynthetic data

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.