SynthForge SynthForge SynthForge IO

Use case · Verified May 2026

Generate test data with foreign keys

If you have ever generated 50,000 customers and 200,000 orders only to discover that half the orders reference customer IDs that do not exist, this page is for you.

Short answer

Define your tables and FK relationships once. SynthForge generates parent rows first, then child rows that draw foreign-key values from the parent IDs that actually exist. Output is ready-to-load DDL and CSV across seven SQL dialects.

The situation

The painful version of this workflow goes: write a Python script with Faker, generate customers, write the customers to a CSV, then write a second script that loads the customer IDs into memory and generates orders by picking randomly from that list. Then you discover line_items also reference orders, so you do it a third time. Then someone changes the schema and you do it all over again.

Or: you use Mockaroo, generate customers, download the CSV, re-upload it as a Dataset, then go to your orders schema and use the Dataset Column type to reference customer IDs. Now do it again for line_items. The result is correct but the workflow is brittle and slow.

SynthForge collapses this into a single operation. You define the schema once. Foreign-key columns reference their parent table by name. The generator runs the tables in dependency order, draws child FK values from the parent IDs that were just generated, and emits the entire dataset in one pass.

How to do it in SynthForge

1. Describe the schema

Type a natural-language description into the AI schema designer (Claude by default), or paste a CREATE TABLE script and let the SQL importer pick out tables and columns. Or build it field-by-field in the visual editor.

2. Mark foreign-key columns

Click a column, set its type to 'foreign key', point it at the parent table.column. Pick a sampling strategy: random (default), uniform across parent rows, sequential (1:N), or weighted.

3. Generate

SynthForge resolves the dependency graph (parents before children) and generates referentially-intact rows in one pass. The cap is 1,000,000 rows per table and 1,000,000 per dataset, with a 200 MB ceiling on the download. A typical 15-column table generates 200,000 rows in about 12 seconds.

4. Export

Choose your dialect: PostgreSQL (with \copy), MySQL (with LOAD DATA INFILE), SQL Server (with bcp), SQLite, MariaDB, DuckDB, or CockroachDB. Or download CSV / JSON / JSONL / Parquet directly.

sql
-- Example output for PostgreSQL
CREATE TABLE customers (
    id      INTEGER PRIMARY KEY,
    name    VARCHAR(120) NOT NULL,
    email   VARCHAR(255) UNIQUE NOT NULL
);

CREATE TABLE orders (
    id          INTEGER PRIMARY KEY,
    customer_id INTEGER NOT NULL,
    total       NUMERIC(10,2) NOT NULL
);

\copy customers FROM 'csv/customers.csv' WITH (FORMAT csv, HEADER true);
\copy orders    FROM 'csv/orders.csv'    WITH (FORMAT csv, HEADER true);

ALTER TABLE orders ADD CONSTRAINT fk_orders_customers_customer_id
    FOREIGN KEY (customer_id) REFERENCES customers(id);

When something else is the right call

Honest alternatives in case SynthForge is not the best fit for your specific situation.

Mockaroo

Pick Mockaroo if you only need a single table at a time. Multi-table FK requires a chained workflow (generate parent, download, re-upload as Dataset, reference from child).

Faker (Python or Faker.js)

Pick Faker if you are writing inline test fixtures inside a unit test and you only need one or two values per record. Faker has no native concept of foreign keys; you write the FK logic yourself.

Tonic Fabricate

Pick Fabricate if you want a chat-based AI agent and you can fit inside a $0/$29/$Enterprise credit-metered model. It also preserves multi-table relational integrity.

Frequently asked questions

Does SynthForge support composite foreign keys?
Not today. Foreign-key columns reference a single parent column. If your schema requires composite FK, plan to model it as a single surrogate key and a separate uniqueness constraint, or generate the parent IDs and bind them yourself.
What about self-referential foreign keys (e.g., employees.manager_id -> employees.id)?
Not supported. A table cannot carry a foreign key to itself, and a schema that tries is rejected before generation. Model the hierarchy as a separate edge table with two FKs to the entity table, for example reporting_lines.employee_id and reporting_lines.manager_id both pointing at employees.id.
How does SynthForge handle many-to-many relationships?
Model the junction table explicitly: create a join table with two FK columns, one to each parent. SynthForge generates the parents, then generates the join table by sampling FK pairs.
Are foreign keys guaranteed to resolve, or can children point to non-existent parents?
Guaranteed. Child FK values are sampled from the parent IDs that were just generated, so every reference resolves by construction.
What's the row cap?
1,000,000 rows per table and 1,000,000 rows per dataset, plus a 200 MB cap on the generated download and per-account rate limits. No daily or monthly request cap. On wide, text-heavy tables the download cap binds first, at roughly 575,000 rows. A typical 15-column table generates 200,000 rows in about 12 seconds.

Related

Other use cases

Ready to get started?

Design a multi-table schema, generate referentially-intact data, and export to your database. No credit card.