Foreign keys

Last modified: 15 May 2024

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.

Foreign keys ( Foreign Key) can be found in the Database tool window. For the reference on other node and object icons, refer to the Data sources and their elements chapter of Database tool window topic. For the table column icons, refer to the Possible icon combinations for columns chapter.

Foreign keys in Database

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