drawDB Docs

Create a database diagram

Create a drawDB diagram, add tables and fields, define indexes and relationships, and export a database schema.

Open the online editor. To replace the currently loaded diagram, choose File → New, then select a blank diagram or template.

The File menu with New highlightedThe File menu with New highlightedThe New diagram dialog with the blank diagram optionThe New diagram dialog with the blank diagram option

Choose a database

Select the database dialect that matches your target:

  • Generic
  • MySQL
  • PostgreSQL
  • SQLite
  • MariaDB
  • Microsoft SQL Server
  • Oracle SQL (Beta)

Database-specific diagrams provide the dialect's native types and features. Generic diagrams use a portable type set and can be exported to multiple SQL dialects.

Database selection options in drawDBDatabase selection options in drawDB

Add tables and fields

Add a table from the sidebar or toolbar, give it a name, and define its fields.

Adding fields to a table in drawDBAdding fields to a table in drawDB

For each field, you can configure:

  • Name and datatype
  • Primary, unique, and not-null constraints
  • Autoincrement where supported
  • Default value and check constraint
  • Comment
  • Array dimensions in PostgreSQL
  • Unsigned numeric types in MySQL and MariaDB

Composite primary keys

Mark multiple fields as primary to generate a composite primary key in SQL output.

Check constraints

Check expressions are inserted into generated SQL as written. Use syntax supported by the target database.

Indexes and unique constraints

Indexes can contain one or more fields and can be named or unique. Tables can also define named, multi-field unique constraints. PostgreSQL diagrams additionally support table inheritance.

Create relationships

Drag from the blue connection point on the foreign-key field to the referenced field. The field types must be compatible. drawDB infers relationship cardinality from primary and unique constraints, and you can adjust it afterward.

Creating a relationship between posts.user_id and users.idCreating a relationship between posts.user_id and users.id

In the example, posts.user_id references users.id. Open the Relationships tab to change the relationship name, swap its foreign and primary sides, configure one or more field pairs, and set labels for the many side.

Both ON DELETE and ON UPDATE support:

  • No action
  • Restrict
  • Cascade
  • Set null
  • Set default

Organize the canvas

Subject areas

Add subject areas from the sidebar or toolbar to visually group related tables. Subject areas improve navigation but do not generate SQL.

Notes

Use notes to capture requirements, decisions, or reminders directly on the diagram.

Custom types and enums

PostgreSQL and Generic diagrams expose a Types tab for diagram-defined composite types. PostgreSQL diagrams also expose an Enums tab. After creating a type or enum, it becomes available when selecting a field datatype.

The Settings menu also lets you configure local custom datatype aliases. These aliases are saved in the browser and are distinct from diagram-defined composite types.

On this page