You can save this relation and use it later or configure rules for virtual foreign keys in settings by using regular expressions. You can still use this virtual relation between the visitor_id field in the activity table and the id field in the visitor table in this JOIN clause. Let's assume that visitor_id is not defined as a foreign key in the database. SELECT * FROM activity JOIN visitor ON visitor_id = visitor.id Alternatively to foreign keys, virtual foreign keys are not defined in the database code. In this case, you can still create foreign key relations without changing your database code. Reasons for not using foreign keys might include performance issues (in CRUD operations), database characteristics (databases like ClickHouse and Apache Cassandra do not support foreign keys), usage of temporary tables (for testing), personal reasons, and other. There are cases when you do not want to use explicitly-defined foreign keys. In the To field, specify the name of the column in the target table. In the From field, specify the name of the column in the child table. In the Columns pane, click the Add button. In the Target table pane, specify the name of the target table. Right-click a child table and select New | Foreign Key.
#Virtual fireign keys dbschema windows#
In the Database Explorer ( View | Tool Windows | Database Explorer), expand the data source tree until the node of a child table. In the following example, activity.activity_id is a primary key, while visitor.activity_id is a foreign key. If your database contains explicit foreign key relationships, DataGrip automatically uses them in auto-completion, data navigation, and diagrams. The table that contains a candidate key is a referenced or target table. The table that contains a foreign key is a child table. FOREIGN KEY (activity_id) REFERENCES activity(activity_id)