Foreign Key Generator

Generate MySQL foreign key constraint statements, define relationships between tables

📖 User Guide

Click to view detailed usage instructions

Expand

Foreign Key Generator

Free online tool to generate MySQL database foreign key constraint statements. Define relationships between tables.

Features

  • Custom foreign key name support
  • Support multiple cascade actions (CASCADE, SET NULL, RESTRICT, NO ACTION)
  • Auto-generate constraint names
  • One-click copy generated SQL

How to Use

  1. Enter child table name and child field
  2. Enter parent table name and parent field
  3. Select cascade actions for DELETE and UPDATE
  4. Click "Generate Foreign Key" button
  5. Copy and execute the generated SQL

Use Cases

  • Database table relationship design
  • Maintain data integrity
  • Create related table structures