Most developers who use ERWIN know it can generate SQL. Fewer than 20% use the forward engineering dialog to its full potential โ€” choosing the right options, applying naming standards, previewing the output, and handling the common problems that cause generated DDL to fail on the first run.

This guide covers the full forward engineering workflow from start to clean, runnable SQL.

What is forward engineering?

Forward engineering is the process of generating SQL DDL (Data Definition Language โ€” CREATE TABLE, CREATE INDEX, ALTER TABLE ADD CONSTRAINT, etc.) from your Physical Data Model. It's the "model to database" direction, as opposed to reverse engineering (database to model).

The output is a .sql file you can run against any instance of your target database to create the schema exactly as designed.

Prerequisites

Step 1: Open the Forward Engineer dialog

ERWIN menu path
Actions โ†’ Forward Engineer โ†’ Schema Generation Report

The dialog has three tabs: Options, Filter, and Preview/Generate.

Step 2: Configure Options tab

This is where most people skip important settings. Here's what to check/uncheck:

OptionCheck?Why
Pre-Schema (DROP statements)โฌœ Usually NoOnly for full recreate โ€” dangerous in production
Tablesโœ… YesCore output
Primary Keysโœ… YesAlways include
Foreign Keysโœ… Yes โ€” but separatelyGenerate after tables to avoid forward-ref errors
Indexesโœ… YesCritical for performance
Defaultsโœ… YesDEFAULT NOW(), DEFAULT TRUE, etc.
Validation Rules (CHECK)โœ… YesStatus enums, range checks
Commentsโœ… YesGenerates COMMENT ON โ€” documentation in the DB
Triggersโฌœ Usually NoOnly if you've defined them in the model

Generation Order โ€” set this to: Tables โ†’ Indexes โ†’ Constraints (FK). This prevents errors where a FK references a table that hasn't been created yet.

Step 3: Apply naming standards first

ERWIN menu path โ€” run BEFORE forward engineering
Tools โ†’ Names โ†’ Apply Naming Standard

This converts your logical names ("Customer ID", "Order Date") into physical column names ("customer_id", "order_date") per your naming standard. If you skip this step, column names in the generated SQL will include spaces and capital letters, which requires quoting everywhere.

Step 4: Preview and save

In the Preview/Generate tab, click Preview first. Read through the output. Common things to check:

When satisfied, click Save to File. Name it with the database version: ecommerce_v1_pg15.sql.

Step 5: Run it against a test database

PostgreSQL โ€” run the generated file
psql -h localhost -U postgres -d mydb -f ecommerce_v1_pg15.sql

Always run against dev/test first. Fix any errors (usually FK ordering or reserved word conflicts), then re-generate. Never run directly against production without reviewing the SQL.

Common errors and fixes

ErrorCauseFix
"relation does not exist" on FKParent table not yet createdCheck generation order โ€” Tables before Constraints
Syntax error near "order"Reserved word used as table nameRename to customer_order or quote: "order"
NOT NULL violation on existing dataAdding NOT NULL to a column with existing rowsAdd default value first, then add constraint separately
Duplicate index nameERWIN auto-naming collisionApply naming standard first; rename conflicting indexes
INTERVIEW TALKING POINT "I treat the data model as the single source of truth and use forward engineering to produce SQL that goes through our standard CI/CD pipeline โ€” reviewed, tested against a dev database, and only then deployed to production via a migration script. Direct database changes outside this process are not allowed."
FULL ERWIN TUTORIAL The Forward/Reverse Engineering lesson in the ERWIN tutorial section covers the Complete Compare feature (model-to-database sync) and reverse engineering in detail.