SynthForge SynthForge SynthForge IO

Integration · CockroachDB · Distributed SQL

Generate CockroachDB test data, with foreign keys intact

Multi-table fixtures that load with userfile upload + IMPORT INTO via import_cockroachdb.sql. Web sessions are free up to 20,000 rows per dataset.

Short answer

Design a multi-table schema in SynthForge, generate, and download the CockroachDB export. You get import_cockroachdb.sql (CREATE TABLE, IMPORT INTO … CSV DATA, then the foreign keys) and per-table CSVs. Upload each CSV to userfile first, then run the script. Every child row references a real parent by construction, and everything lands in a synthforge_import schema.

See the data

first_name last_name date_of_birth
Tammy Morrow 1969-08-30
Paul Pisacane 1913-10-03
Raymond Leung 1951-01-30
Hildreth Lowery 1918-05-10
Joseph Torres 1950-04-28
Robert Mote 1936-09-25
Kaylee Bean 2023-03-24
Marcella Noha 2010-03-17
Sierra Jenkins 2000-09-11
Monique McGreevy 2006-08-16
Reese Blair 2016-01-18
Montana Friel 2004-05-09

Person names follow US Census and SSA frequencies. First names match birth year on the same row.

Download sample pack customers, products, orders, order_items · SQL + CSV · No signup required

Try these after you load the pack

sql · orphan check (expect 0)
SELECT COUNT(*) AS orphan_orders
FROM synthforge_import.orders o
LEFT JOIN synthforge_import.customers c ON o.customer_id = c.customer_id
WHERE c.customer_id IS NULL;
sql · top surnames
SELECT last_name, COUNT(*) AS n,
       ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER (), 3) AS pct
FROM synthforge_import.customers
GROUP BY last_name
ORDER BY n DESC
LIMIT 10;
sql · 1950s first-name cohort
SELECT first_name, COUNT(*) AS n
FROM synthforge_import.customers
WHERE EXTRACT(YEAR FROM CAST(date_of_birth AS DATE)) BETWEEN 1950 AND 1959
GROUP BY first_name
ORDER BY n DESC
LIMIT 10;

Why generate rather than hand-roll

Distributed SQL still needs multi-table fixtures for integration tests and staging. Hand-rolled seed scripts drift; broken foreign keys fail later under concurrency.

SynthForge sorts tables by dependency, generates parents first, and samples FKs from IDs that exist. The same schema also exports Postgres-style loaders when you run CRDB and Postgres side by side.

How to do it

1. Define the schema

Describe tables in plain English, build them in the visual editor, or paste CREATE TABLE DDL. AI forge and SQL import both produce multi-table schemas with single-column foreign keys.

2. Set cardinality (optional)

Use relationship ratios such as "1 to 4 orders per customer" instead of inventing every child row count. Parents generate first; child foreign keys are sampled from real parent IDs.

3. Generate and export CockroachDB

Pick CockroachDB as the SQL dialect (or include SQL export in formats). The download ZIP contains import_cockroachdb.sql (CREATE TABLE, IMPORT INTO … CSV DATA loaders, then ALTER TABLE ADD CONSTRAINT for the foreign keys) and csv/<table>.csv data files. Everything is created in a synthforge_import schema. Types use STRING, INT, and JSONB-friendly mappings.

4. Upload CSVs to userfile, then run the import script

CockroachDB IMPORT INTO reads from userfile:// (or cloud storage URLs), not from arbitrary local paths. The script header documents the prerequisite. Extract the ZIP, upload each CSV so the destination path matches userfile:///csv/<table>.csv, then run the SQL script.

bash
# From the extracted bundle directory
export DATABASE_URL='postgresql://root@localhost:26257/defaultdb?sslmode=disable'
# or your Cockroach Cloud connection string

for f in csv/*.csv; do
  base=$(basename "$f")
  cockroach userfile upload "$f" "csv/$base" --url "$DATABASE_URL"
done

cockroach sql --url "$DATABASE_URL" -f import_cockroachdb.sql

# The tables land in a synthforge_import schema:
#   SELECT count(*) FROM synthforge_import.customers;
#
# Somewhere else? Find and replace synthforge_import first.

# Loaders look like:
#   IMPORT INTO "customers" CSV DATA ('userfile:///csv/customers.csv')
#   WITH skip = '1', nullif = '';
#   IMPORT INTO "orders"    CSV DATA ('userfile:///csv/orders.csv')
#   WITH skip = '1', nullif = '';

5. Local single-node / Docker tip

For a quick local check, start an insecure single-node (dev only), upload, and import. Production Cockroach Cloud uses the same userfile (or external storage) pattern with TLS credentials.

bash
# Dev only
docker run -d --name crdb -p 26257:26257 cockroachdb/cockroach:latest-v24.3 \
  start-single-node --insecure

# then userfile upload + cockroach sql -f import_cockroachdb.sql as above

6. (Optional) Agent path

With an API key and hosted MCP, agents can run description_to_dataset, download the ZIP, upload userfiles, and load with the same import_cockroachdb.sql. First API key includes 250 free credits.

text
# MCP endpoint: https://mcp.synthforge.io/mcp
# Auth: Authorization: Bearer sfk_live_…
# Docs: https://synthforge.io/docs/mcp

Frequently asked questions

Why userfile upload before IMPORT?
CockroachDB IMPORT INTO CSV DATA expects a storage URL the cluster can read (userfile://, s3://, gs://, …), not a bare path on your laptop. The import_cockroachdb.sql header documents cockroach userfile upload csv/<table>.csv csv/<table>.csv. Our load harness runs that step before IMPORT and checks row counts and FK orphans.
Does CockroachDB enforce the foreign keys?
Yes. SynthForge emits ALTER TABLE … ADD CONSTRAINT FOREIGN KEY after IMPORT, and the data is referentially valid by construction: child keys are drawn from generated parent IDs.
Does this work with Cockroach Cloud?
Yes, with a Cloud connection string (TLS). Use the same userfile upload + import_cockroachdb.sql flow, or point IMPORT at cloud object storage if your ops prefers that over userfile.
How large a dataset can I generate?
Up to 1,000,000 rows per table. The first 20,000 rows of a dataset are free; larger runs use credits, from about 2 credits for a small dataset to 41 for a full 1,000,000-row dataset, plus a 200 MB cap on the generated download and per-account rate limits. The download cap is what binds on wide, text-heavy tables: 25 columns including free text reaches 200 MB at roughly 575,000 rows. A typical 15-column table generates 200,000 rows in about 12 seconds.
Can I use the same schema for Postgres or SQL Server?
Yes. One schema exports to PostgreSQL, MySQL, SQLite, SQL Server, MariaDB, DuckDB, and CockroachDB, plus CSV, JSON, JSONL, and Parquet. Cockroach wire protocol is Postgres-compatible, but the loader script is dialect-specific (IMPORT INTO vs \\copy).
Does SynthForge use my real production data?
No. It generates greenfield data from the schema you provide. It does not ingest or de-identify a live database. For anonymizing real data, use tools like Tonic or NVIDIA NeMo.

Related

Ready to seed CockroachDB staging?

Generate multi-table Cockroach data with real foreign keys, upload to userfile, IMPORT once. No credit card for the web app.