On this page
Synthetic relational database generation means creating a complete test database (tables, rows, primary keys, foreign keys and indexes) that behaves like a real one, without copying any real rows. A good synthetic database keeps the schema, the relationships between tables and the statistical shape of each column, so queries, joins and application code run against it the way they run against production.
This guide explains why that is harder than it sounds, how the common approaches compare, and what to check before you choose a tool.
Why relational data is the hard part
Generating one realistic table is easy. A list of fake names and email addresses takes a few lines of code. A relational database is a different problem, because its value is in the connections:
- Every foreign key must point at a real parent row. An order without a customer, or a payment without an order, breaks joins and fails constraint checks on load.
- Ratios between tables matter. If the source has about 30 rentals per customer, a test database with 1 rental per customer will hide the slow query that only appears on large child tables.
- Columns depend on each other. Ship dates come after order dates, cities belong to countries, and status values follow real distributions rather than a uniform random pick.
- Reference data should stay small. Countries, currencies and categories should not grow by 100 times when you scale the fact tables.
- Composite and self-referencing keys exist. Employee-manager hierarchies and many-to-many link tables have to stay valid too.
A generator that ignores these rules produces data that loads, at best, and tells you nothing about how the application behaves on real data.
The four common approaches
| Approach | How it works | Privacy | Realism | Effort |
|---|---|---|---|---|
| Hand-written seed scripts | Developers write INSERTs or fixtures by hand | Safe | Low: few rows, few edge cases | High and ongoing |
| Random data libraries (Faker style) | Code fills each column with plausible values | Safe | Medium per column, weak across tables | High: you write the relational logic |
| Masked production copy | Copy production, then mask sensitive columns | Real rows remain, only some columns are changed | High | Slow refreshes, large storage, audit scope |
| Profile-based synthetic generation | Learn the schema, relationships and value patterns once, then generate new rows | No production rows copied | High, including relationships | Low after the first profile |
Masked copies and subsets are still the right choice when a test needs the real records, for example to reproduce a specific customer’s bug. When a test needs data that behaves like production rather than the production rows themselves, profile-based generation removes the copy entirely.
How profile-based generation works
The profile-based method has two phases.
- Analyze once. The tool connects read-only to the source database and records the schema, primary and foreign keys, table sizes and ratios, and value patterns per column. The result is a compact profile file: a recipe, not a copy.
- Generate as often as you like. From the profile alone, the generator creates parent tables before child tables, assigns every child a valid parent key, and fills each column from its learned pattern. It can scale the whole database up or down while keeping the ratios.
Because the second phase needs only the profile, it can run on a laptop, in a CI job or in an air-gapped network, with no further access to production.
A checklist for choosing a synthetic database generator
Before you adopt a tool, check these points against your own schema:
- Referential integrity on load. Load the output into a real engine with constraints enabled. Count broken foreign keys. The right number is zero.
- Engines you actually run. PostgreSQL, MySQL, SQL Server and Oracle each have their own types, identity columns and bulk loaders.
- Where the data goes. Does profiling or generation send rows, samples or the schema to a cloud service or an external AI API? For regulated data (KVKK, GDPR, HIPAA) the safest answer is no.
- What the profile keeps. A profile should be reviewable. Ask whether it can contain literal values such as names or credentials, and whether the tool audits it before it leaves your team.
- Scale control. You should be able to ask for a 1% copy for unit tests and a much larger one for load tests from the same profile.
- Reproducibility. The same profile, settings and seed should give the same database, so a failing CI run can be repeated exactly.
- Output that fits your pipeline. SQL files, native bulk-loader files, or a database loaded straight into Docker for ephemeral test environments.
- Measured realism. Ask for a column-by-column comparison between the source and the synthetic output, not just screenshots.
How Lyrebird does it
Lyrebird is Subsetra’s synthetic relational database generator, built around the profile-based method above.
- Connect once, read-only. Lyrebird captures the schema, relationships and value patterns in a profile file, usually a few megabytes. Generation never reconnects to the source.
- Every foreign key intact. It builds a dependency graph of the schema, generates parents before children, and keeps composite keys and foreign-key constraints valid across the whole database.
- Fully offline, including the AI. Profiling and generation run on your own machines with a local model. There is no cloud service and no external AI API.
- Four engines, across engines. Profile PostgreSQL, MySQL, SQL Server or Oracle, and generate for the same engine or another one.
- Sized to the job. Scale every table by a factor, from a small 1% copy to a much larger load-test database, or set total and per-table row counts, with table ratios preserved.
- Reproducible output. SQL files with a manifest, native bulk-loader files for SQL Server and Oracle, or a database loaded straight into Docker.
You can see the results before installing anything. The sample data pages compare four public databases (Pagila, Chinook, AdventureWorksLT and Oracle HR) with their synthetic copies, table by table. In a CI-style run on a laptop, Lyrebird created 10 million foreign-key-consistent rows in PostgreSQL in about 52 seconds.
Lyrebird Community is free and generates up to 5,000 rows per table. Enterprise removes that limit and adds a headless CLI for CI/CD pipelines.
Frequently asked questions
What is a synthetic relational database? A test database whose tables, keys and value patterns mirror a real database, filled with newly generated rows instead of copied ones. Joins and constraints work because every foreign key points to a generated parent row.
Is synthetic data the same as masked data? No. Masking changes selected columns in real rows, so the real records still exist in the test environment. Synthetic generation creates new rows, so no production row is copied.
Can synthetic data keep foreign keys and referential integrity? Yes, if the generator works from the schema graph. Generating parent tables first and drawing child keys only from existing parents gives a database with zero broken foreign keys.
Do I need a connection to production to generate data? Only once, to build the profile. After that, generation runs from the profile file alone, offline.
Which databases are supported? Lyrebird supports PostgreSQL, MySQL, SQL Server and Oracle, on Linux, macOS and Windows.
Download Lyrebird Community and generate a database from a sample profile, or book a demo to see it run on your own schema.