Yes. For MySQL and PostgreSQL data sources, Chartio automatically detects foreign key relations between your tables when it imports your schema and joins are automatically built into your queries when dragging columns from related tables in the Data Explorer.
If there are no foreign keys in your Chartio schema—either because Chartio is unable to access them or they don’t exist—you can specify the joins in the schema editor for your database.
If no foreign keys are set up in your Schema, Chartio will suggest possible foreign keys for you using the Connect Tables feature. You can review and approve the foreign key selections before they’re added to your Chartio schema. Note: foreign keys are only added to Chartio’s metadata, we don’t make any changes to the database itself.
Manually Add Foreign Keys
If no foreign keys are detected or if you want to change existing ones, you can edit them manually in the Schema.
In the example below, we’ll click Activity to expand the Activity table. Then, we’ll click User Id to open the User Id column’s settings. In the Foreign Key dropdown, we’ll select the Users table, then select the Id column. This will create a join between our Activity and Users tables.
If you’re modifying foreign keys, make sure to remove the old foreign key using the same steps as above.
Note: Changing foreign keys in your schema will affect charts using this data source. We suggest setting up your foreign keys as soon as you add a new data source.
Read more about manually setting up foreign keys here.