gi.validate.check_foreign_key

gi.validate.check_foreign_key(foreign_key, parent_table, table_with_foreign_key)

Validates referential integrity between two tables by checking foreign key relationships.

This function ensures that all foreign key values in a child table exist in the corresponding parent table, maintaining data integrity in the GIS database.

Parameters

Name Type Description Default
foreign_key str The name of the column that serves as the foreign key. required
parent_table Union[pd.DataFrame, gpd.GeoDataFrame] The parent table containing the primary keys. required
table_with_foreign_key Union[pd.DataFrame, gpd.GeoDataFrame] The child table containing the foreign keys. required

Returns

Name Type Description
bool bool True if all foreign keys exist in the parent table.

Raises

Name Type Description
ValueError If any foreign key values in the child table do not exist in the parent table.

Example

check_foreign_key("project_uid", projects_df, locations_df)