Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #375 #411

Merged
merged 43 commits into from Nov 17, 2020
Merged

Issue #375 #411

merged 43 commits into from Nov 17, 2020

Conversation

jawond
Copy link
Contributor

@jawond jawond commented Jul 1, 2020

@krlmlr first partial draft of persistence tutorials. Got stuck loading data into a dm.

Closes #375.

vignettes/howto-dm-rows.Rmd Outdated Show resolved Hide resolved
vignettes/howto-dm-rows.Rmd Outdated Show resolved Hide resolved
@krlmlr krlmlr changed the title Issue 375 Issue #375 Jul 1, 2020
Copy link
Collaborator

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks great.

  • howto-dm-load.Rmd looks like a copy of howto-dm-db.Rmd. I like the old name better. Should we copy over and consolidate the cross references?
  • howto-dm-persist.Rmd looks like an unfinished stub, do we still need it?
  • I tweaked a bit, please pull from the branch before you resume.

Using {dm} you can persist an entire relational model with a single function call or piece by piece.
`copy_dm_to()` will move your entire model into a destination RDBMS.
This may be all you need to deploy a new data model.
Considerations for which approach to use depend on a number of factors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to mention compute() here?

In this tutorial we run through techniques for persisting an entire relational model as well as individual tables.
For modifying and persisting changes to your relational model at the row-level see `vignette("howto-dm-rows")`.

## Copying a complete relational model
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this section be named "Overview" or similar?

| dm_rows_truncate() | Removes all records, only for tables in dm. Truncation is performed by truncating child tables before parent tables. |

For `dm_rows_delete()` and `dm_rows_truncate()` tables linked to other tables via foreign keys are processed first.
For example, a database of nations with three linked tables, Country <- Province <- City.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would howto-dm-theory.Rmd be a better fit for this example?

Table modification methods work as expected on local dm objects, returning a new dm with the modifications in place.
dm objects whose source is a database treat all operations as temporary unless you request explicitly to commit them by including the argument `temporary=FALSE`.

Below we copy `demo_dm` into an SQLite database.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we start by copying the empty structure into the database and then adding the rows with copy_dm_to(temporary = FALSE) %>% dm_rows_insert() ? It's good practice to separate model creation from database population.

@krlmlr krlmlr merged commit d92fb2b into cynkra:master Nov 17, 2020
@krlmlr krlmlr deleted the Issue-375 branch November 17, 2020 07:35
@krlmlr
Copy link
Collaborator

krlmlr commented Nov 17, 2020

Thanks!

krlmlr added a commit that referenced this pull request Nov 19, 2020
dm 0.1.9

- New `vignette("howto-dm-copy", package = "dm")` and `vignette("howto-dm-rows", package = "dm")` discuss updating data on the database. In part derived from `vignette("howto-dm-db", package = "dm")` (#411, @jawond).
- New `dm_mutate_tbl()` (#448).
- `dm_financial()` falls back to db-edu.pacha.dev if relational.fit.cvut.cz is unavailable (#446, @pachamaltese).
- Use testthat 3e (#455).
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Document persistence
2 participants