Seed Multiple Related Tables at Once
Generate INSERT statements for multiple interconnected tables from a single SQL schema. Learn how to paste multiple CREATE TABLE statements.
Detailed Explanation
Multi-Table Seed Generation
Real applications have interconnected tables. The seed generator accepts multiple CREATE TABLE statements and produces seed data for all of them in a single operation.
Example Multi-Table Schema
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE categories (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
description TEXT
);
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
title VARCHAR(200) NOT NULL,
body TEXT,
author_id INTEGER NOT NULL REFERENCES users(id),
category_id INTEGER REFERENCES categories(id),
published BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE comments (
id SERIAL PRIMARY KEY,
post_id INTEGER NOT NULL REFERENCES posts(id),
user_id INTEGER NOT NULL REFERENCES users(id),
body TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Output Order
The generator produces INSERT statements in the order tables appear in the input. For referential integrity, paste parent tables first:
users(no dependencies)categories(no dependencies)posts(depends on users, categories)comments(depends on posts, users)
JSON Multi-Table Output
In JSON format, the output becomes a single object with table names as keys:
{
"users": [ ... 10 objects ... ],
"categories": [ ... 10 objects ... ],
"posts": [ ... 10 objects ... ],
"comments": [ ... 10 objects ... ]
}
CSV Multi-Table Output
In CSV format, each table is separated by a comment header:
# Table: users
id,username,email,created_at
...
# Table: categories
id,name,description
...
Row Count Applies to All Tables
The row count slider applies uniformly to all tables. If you set 50 rows, every table gets 50 rows. For schemas where parent tables should have fewer rows than child tables, you may want to generate them separately with different row counts.
Use Case
You are building a blog platform with users, categories, posts, and comments. You need to populate all four tables with test data in a single operation to quickly set up a development database where you can test the full content hierarchy.