# NOT RUN {
nycflights_dm <- dm(
planes = nycflights13::planes,
flights = nycflights13::flights,
weather = nycflights13::weather
)
nycflights_dm %>%
dm_draw()
# Create foreign keys:
nycflights_dm %>%
dm_add_pk(planes, tailnum) %>%
dm_add_fk(flights, tailnum, planes) %>%
dm_add_pk(weather, c(origin, time_hour)) %>%
dm_add_fk(flights, c(origin, time_hour), weather) %>%
dm_draw()
# Keys can be checked during creation:
try(
nycflights_dm %>%
dm_add_pk(planes, tailnum) %>%
dm_add_fk(flights, tailnum, planes, check = TRUE)
)
# }
Run the code above in your browser using DataLab