From caa8efb96982f7db378ba1e8ee467040fa25e896 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 28 Oct 2017 09:01:12 -0400 Subject: fix db stuff. --- db.Rmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'db.Rmd') diff --git a/db.Rmd b/db.Rmd index 5df6a06..2b84a3a 100644 --- a/db.Rmd +++ b/db.Rmd @@ -14,7 +14,6 @@ tasks <- data.table( owner = c('Alice,Bob', 'Bob', 'Alice') ) setkey(tasks, task_id) - kable(tasks) ``` @@ -24,8 +23,8 @@ of a task. ```{r result='asis'} owners <- tasks[, .(owner=unlist(strsplit(owner, ','))), by=.(task_id)] setkey(owners, task_id, owner) - kable(owners) +kable(tasks[, owner := NULL]) ``` # Second normal form @@ -55,7 +54,8 @@ kable(task_dependencies[, dependent_target_date := NULL][]) We can still get the target dates by joining: ```{r result='asis'} -kable(tasks[task_dependencies, on=.(task_id = depends_on)]) +kable(tasks[task_dependencies, on=.(task_id = depends_on), + .(task_id, depends_on, target_date)]) ``` # Third normal form @@ -76,5 +76,5 @@ not the primary key. ```{r result='asis'} categories <- tasks[, .(category, location = category_location)] kable(categories) -kable(tasks[, `:=`(category = NULL)][]) +kable(tasks[, `:=`(category_location = NULL)][]) ``` \ No newline at end of file -- cgit v1.2.3