check.link | R Documentation |
Check for violation of a foreign key constraint
check.link( child.tbl, child.col, parent.tbl, parent.col, na.ok = FALSE, silent = FALSE )
child.tbl |
Data frame representing the table on the 'many' side of an 'one-to-many' relation. See notes. |
child.col |
Name of a column from |
parent.tbl |
Data frame representing the table on the 'one' side of an 'one-to-many' relation. See notes. |
parent.col |
Name of a column from |
na.ok |
Logical. Allow |
silent |
Logical. If |
TRUE
if the check was passed successfully and
FALSE
otherwise.
The function is made to verify that two tables having a one-to-many relation (https://en.wikipedia.org/wiki/One-to-many_(data_model)) can successfully be joined on the specified columns.
David Kneis david.kneis@tu-dresden.de
There are more functions to check constraints, namely
check.notnull
, check.unique
,
and check.key
.
See also the example for db.read
.
data(people, countries) print(people) print(countries) # Should succeed check.link(people, "id_country", countries, "id") # Example of an orphaned child record check.link(people, "id_country", countries[1:2,], "id") # Example of ambiguity countries2 <- rbind(countries, data.frame(id=3, country="India")) check.link(people, "id_country", countries2, "id")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.