WebStorm
 
Get WebStorm
You are viewing the documentation for an earlier version of WebStorm.

Foreign keys

Last modified: 27 June 2022

This feature is available with the Database Tools and SQL plugin installed on the Settings/Preferences | Plugins page, tab Marketplace, as described in Installing plugins from JetBrains repository.

Please note that it is a paid plugin.

Foreign key relationships specify how tables relate to each other and indicate relationships between tables. WebStorm recognizes foreign key relationships in your database schema and uses them to construct JOIN clauses. You can see these relationships in the auto-completion list, data navigation, and diagrams.

In WebStorm, you can use explicit foreign keys or create virtual foreign keys.

A foreign key is a field or a collection of fields in one table that refers to the primary key in another table. When you create or modify a table, you can clearly define those keys:

The table that contains a foreign key is a child table. The table that contains a candidate key is a referenced or target table. If your database contains explicit foreign key relationships, WebStorm automatically uses them in auto-completion, data navigation, and diagrams.

In the following example, activity.activity_id is a primary key, while visitor.activity_id is a foreign key.

Explicit foreign keys