dm (version 0.0.3.9003)

cdm_enum_fk_candidates: Find foreign key candidates in a table

Description

Which columns are good candidates as a foreign key of a table, referencing the primary key column of another dm object's table?

Usage

cdm_enum_fk_candidates(dm, table, ref_table)

Arguments

dm

A dm object.

table

The table whose columns should be tested for foreign key candidate potential

ref_table

A table with a primary key.

Value

A table with an overview which columns of table would be suitable candidates as foreign key columns referencing ref_table and which columns would not.

Details

cdm_enum_fk_candidates() checks first, if ref_table has a primary key set. For each column of table a join operation is then tried, with parameter by matching the respective column with the primary key of ref_table. This tests implicitly for type compatibility (on most sources). Based on the result of the join, the entry in the result column why is:

  • an empty entry, if the column is a candidate

  • the total percentage and individual numbers of missing matches between the entries of the respective column in table table and the primary column entries in table ref_table.

  • the error message triggered by the error (often stating the mismatched column types)

See Also

Other foreign key functions: cdm_add_fk, cdm_get_all_fks, cdm_get_fk, cdm_has_fk, cdm_rm_fk

Examples

Run this code
# NOT RUN {
cdm_enum_fk_candidates(cdm_nycflights13(), flights, airports)

# }

Run the code above in your browser using DataCamp Workspace