This tutorial will show you how to view foreign keys using DataGrip.
Before both options
From View -> Tool Windows in toolbar select Database (or press Alt + 1).
Fig. 1. Database in toolbar
Option 1: Table details
In opened explorer search for table which foreign keys you want to see. You can identify foreign keys in two ways:
- first is to look for blue key icon next to the list of table objects, right click on it and select Modify Foreign Key...
Fig. 2. Modify Foreign Key option
- second one is to right click on table name and select Modify Table. In new window switch to Foreign Keys tab
Both actions opens the same window which contains all FK information like parent table, used columns and modify rules.
Fig. 3. Foreign Keys details
Option 2: ER Diagram
In Database explorer find table like in previous option, but this time instead of clicking on Modify Table option in context menu, select Diagrams -> Show Visualization…
Fig. 4. Diagrams in table context menu
This will result in generating database diagram with this table and full chain of related tables like in example below:
Fig. 5. Tables relation chain
If you want to know more about any relation, unfortunately you can do this only by right click on appropriate table and selecting Refactor -> Modify table which leads to same options as in Option 1.
Fig. 6. Refactor options in Diagram workspace