zinternal_CreateOneJointTable: Create Extended Main Joint Tables

Description Usage Arguments Examples

View source: R/CreateOneJointTable.R

Description

Get 1 table containing the information that main_joint_tables contained joined as given in "db_forced_rel" WITH or WITHOUT Renames as given by "db_ColumnsOldNamesToNewNames"

Usage

1
2
3
4
5
6
7
8
zinternal_CreateOneJointTable(
  main_joint_tables,
  db_fields,
  db_forced_rel,
  con = db$con,
  Verbose = TRUE,
  get_sql_query = TRUE
)

Arguments

main_joint_tables

A named list of tibbles/DFs (usually given by create_main_joint_tables() as a SQL DB Pointer containing all user-selected fields plus needed ones for joins

db_fields

A DF with columns: "Include, KeyType, Table, Column, Type, RelationshipWithTable, RelationshipWithColumn, Transformation, Comment" about the User Selected fields and Relationships

db_forced_rel

A Named String Vector. The vector names MUST point to the main table to be used for the 1-Joint-Table as its LHS. e.g. c(Hours_SiteID = "Site_SiteID", Hours_EmployeeID = "Employee_ID")

con

is a dbConnect DBI connection object to a SQL Database

Verbose

A Boolean. Verbose = TRUE will output the consecutive joins as they happen

get_sql_query

A Boolean. get_sql_query = TRUE will create/edit the db$sql_main_joint_tables that output the SQL Code for the tables

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
db_forced_rel <- c(Hours_SiteID = "Site_SiteID", Hours_EmployeeID = "Employee_ID")
Example 1:
joint_table_Without_extended_joins <-
  create_main_joint_tables(db_fields, db_forced_rel, FALSE, db$con) %>%
  zinternal_CreateOneJointTable(db_fields, db$con, db_forced_rel)

print(joint_table_Without_extended_joins)
#No renames are used and therefore no extended joins.
#This assumes that all tables can be joined together without any 1 table being needed twice.


Example 2:
joint_table_With_extended_joins <-
  create_main_joint_tables(db_fields, db_forced_rel, FALSE, db$con) %>%
  zinternal_CreateExtendedMainJointTables(db_fields, db$con, c("DIM_Employee"), db_forced_rel) %>%
  zinternal_CreateOneJointTable(db_fields, db$con, db_forced_rel)

print(joint_table_Without_extended_joins)
#Renames as given by "db_ColumnsOldNamesToNewNames", create extended joins on main_joint_tables for foreign tables that hold different meaning depending on which table they are joined with, and then everything is joined into 1 table as given by the relationships on "db_forced_rel"

N1h1l1sT/dbautojoinr documentation built on Jan. 24, 2021, 10:15 a.m.