Use dplyr::copy_to() to create multiple related tables

So it's possible to create a table in a database using dplyr::copy_to(), but wouldn't it be cool if instead of creating ONE table it could optionally create multiple related tables (if specified to do so by the user)?

For example, consider the following dataset:

If we wanted to convert this to a database schema, it probably makes more sense to convert this into two related tables:

which are linked together as such:
image

The fields could be mapped to one table or another using new inputs from the user, or by requiring a separate data.frame where the table-fields are mapped, or other hacky methods.

So I have two questions:

  1. Do you all think it's a good idea? To be able to engineer a database from R?
  2. Do you think dplyr is the correct place for this? or should I create a separate package for this functionality.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.