Prompts: Review DDL & Generate Test Data
Prompts #9 and #10: a five-point design review of your tables, and realistic test INSERTs with valid keys.
AI is very good at two database-design chores: reviewing table definitions and inventing test data. Both save time, and both need a careful human check.
Definition
A DDL review checks a
CREATE TABLEscript for naming, data types, keys, indexes and normalization. Test data generation produces small, realisticINSERTstatements that respect the tables' primary and foreign keys.
Prompt #9 — Improve database DDL
text
The following SQL Server DDL script has to be optimized.
Do the following:
1. Naming - check the consistency of table/column names, prefixes, standards.
2. Data Types - ensure data types are appropriate and optimized.
3. Integrity - verify the integrity of primary keys and foreign keys.
4. Indexes - ensure indexes are sufficient and avoid redundancy.
5. Normalization - ensure proper normalization and avoid redundancy.
[ SQL DDL GOES HERE ]The five review areas:
| Area | What the AI checks | Bad sign |
|---|---|---|
| Naming | Consistent, readable names | Players, nm, tblPlayer mixed together |
| Data types | Right type and size per column | runs varchar(255) (numbers stored as text) |
| Integrity | Primary keys and foreign keys | No primary key; team not linked to teams |
| Indexes | Enough indexes, no duplicates | Two indexes on the same column |
| Normalization | No repeated data | Team name and city copied into every player row |
sql
-- before
CREATE TABLE Players (
ID varchar(255),
nm varchar(255),
runs varchar(255)
);
-- after
CREATE TABLE players (
id INT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
runs INT DEFAULT 0
);The "after" version uses a numeric primary key, a readable column name with a sensible size, NOT NULL where a value is required, and a numeric runs with a default. Compare it with the rules in the DDL chapter.
Prompt #10 — Generate a test dataset
text
I need dataset for testing the following SQL Server DDL.
Do the following:
1. Generate test dataset as Insert statements.
2. Dataset should be realistic.
3. Keep the dataset small.
4. Ensure all primary/foreign key relationships are valid (use matching IDs).
5. Don't introduce any Null values.
[ SQL DDL GOES HERE ]sql
INSERT INTO teams VALUES
('RCB', 'Royal Challengers', 'Bengaluru'),
('MI', 'Mumbai Indians', 'Mumbai');
INSERT INTO players VALUES
(1, 'Virat Kohli', 'RCB', 'India', 750),
(2, 'Rohit Sharma', 'MI', 'India', 500);Why it works: it sets the size and realism, keeps keys consistent, and returns ready-to-run INSERTs.
Note: Review before you run it. Check the column order matches your table, that every foreign key value exists in the parent table, and that the numbers are plausible.
Common mistakes
- ❌ Accepting a redesign that renames columns your application already uses. ✅ Ask the AI to list breaking changes separately.
- ❌ Inserting child rows before parent rows. ✅ Insert
teamsfirst, thenplayers, so foreign keys are satisfied.
Key points to remember
- Prompt #9 reviews DDL in five areas: naming, data types, integrity (PK/FK), indexes and normalization.
- Classic DDL smells: numbers stored as varchar, no primary key, cryptic names like 'nm', duplicated data.
- Prompt #10 generates small, realistic INSERT statements with valid primary/foreign key relationships.
- Insert parent rows (teams) before child rows (players) so foreign keys are satisfied.
- Always review AI-generated DDL and data before running it: column order, key matches, plausible values.
Try it yourself
Prompt #9: the reviewed table definition
Runs on a fresh IPL practice database in your browser · edit the query and press Ctrl + Enter
Prompt #10: test data with valid keys
Runs on a fresh IPL practice database in your browser · edit the query and press Ctrl + Enter
Practice: spot what's wrong with this AI data
Runs on a fresh IPL practice database in your browser · edit the query and press Ctrl + Enter
Revision Flashcards
Tap a card to flip it and see the answer.
