Use foreign key scanner
You can use the foreign key scanner to make it easier to discover virtual foreign keys.
Select the Foreign keys tab on the Job configuration screen.
Press the Scan button to launch a foreign key scan.
Select any filters to apply to limit the amount of foreign key candidates.
Finally, select Confirm to launch your foreign key scan.
Once the foreign key scan is complete, you can view, confirm, or delete any foreign key candidates resulting from the scan.
Filter foreign key candidates
To confirm starting a foreign key scan, you can enable or disable filters to limit the foreign key candidates - columns that are considered as possible foreign key options - for the scan.
Only include exact column name matches: When enabled, only column pairs with the exact same column names are considered foreign key candidates. When disabled, column names are not considered to limit the possible foreign key candidates.
Only include exact data type matches: When enabled, only column pairs with the exact same data types are considered foreign key candidates. When disabled, two columns must still have a compatible data type, but it does not need to be an exact match.
FK candidates must link to an existing primary key: When enabled, foreign key candidates must always link to an existing primary key column. When disabled, foreign key candidates can also be columns that are not defined as primary keys in the database, but can be identified as primary keys based on Syntho logic, considering the cardinality of the columns.
Include string values as primary key candidates: When enabled, columns with a data type that matches a String type (e.g.
VARCHAR
andTEXT
) are included as possible candidates. When disabled, String type columns are excluded as possible foreign key candidates.
Apply bi-directional data validation: When enabled, column pairs are considered, with the values in column A also appearing in column B and the values in column B also appearing in column A. When disabled, one-way validation applies, requiring either the values from column A to exist in column B, and/or vice versa.
Applying filters reduces the list of foreign key candidates, but is likely to result in a higher proportion of foreign key suggestions that are correct.
Limitations of the foreign key scanner
It is important to consider several characteristics of the foreign key scanner:
Performance on Large Databases: Although the foreign key scanner is designed to operate in parallel for efficiency, scanning databases with hundreds of millions of rows will still take a considerable amount of time.
No Support for Composite Foreign Keys: The scanner doesn't take into account composite foreign keys; it only considers individual columns.
Assumptions on Database Structure: The scanner operates based on certain assumptions about the database, such as descriptive column names and correctly defined data types. If your database doesn't follow standard design best practices, you should disable the strict matching criteria for both column names and data types to allow the identification of more potential foreign key relationships.
Indeterminate Foreign Key Direction: Sometimes, Syntho may not be able to determine the direction of a foreign key relationship (i.e., whether column A points to column B or vice versa). In such cases, both options will appear in the foreign key list, and manual review is strongly advised to validate the results.
Understanding these limitations will help you use the foreign key scanner more effectively and be aware of its constraints.
Last updated