Skip to content

Relationships and Foreign Keys

Relationships in DBModeler are foreign-key constraints represented visually in the diagram. They connect tables, drive cardinality, and influence generated SQL.

Start from a source field and connect it to a target table or target field.

During creation, DBModeler can capture:

  • relationship or constraint name
  • source and target fields
  • delete action
  • update action

The available action list depends on the selected database engine.

DBModeler infers relationship shape from the target side.

  • If the target is unique or primary-key-backed, the relationship can behave as one-to-one.
  • Otherwise the common result is one-to-many.

This is reflected visually in the relationship line and becomes part of the SQL definition.

Open the relationship properties dialog when you need to adjust:

  • the constraint name
  • linked fields
  • delete or update actions

This is the right place to refine a relationship after the initial drag-to-connect flow.

Foreign-key conflicts can appear when:

  • the target engine does not support a requested action
  • a relationship needs a field that already exists in a conflicting form
  • imported SQL contains constraints that do not map cleanly to the current engine rules

DBModeler can guide you through whether to reuse an existing field or create a new one.

Not every engine supports every foreign-key action. For example, some engines are stricter about ON UPDATE behavior than others.

When an action is unsupported, DBModeler validates it before export and can degrade the generated clause instead of emitting invalid SQL.

  • Target primary or unique keys when the relationship should be stable.
  • Review action choices before finalizing a version.
  • Re-run SQL preview after changing relationship behavior.
  • Use version checkpoints before renaming or restructuring heavily referenced tables.

Next: Export SQL