-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path020-010 Create the Job TABLE for the dev SCHEMA.R
More file actions
84 lines (66 loc) · 2.39 KB
/
Copy path020-010 Create the Job TABLE for the dev SCHEMA.R
File metadata and controls
84 lines (66 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
library(uuid)
library(tibble)
library(dplyr)
library(here)
N_JOB_UUIDS <- 20 # N_JOB_UUIDS must equal N_EMPLOYEE_UUIDS
N_EMPLOYEE_UUIDS <- N_JOB_UUIDS # because of the data model constraints
N_COMPANY_UUIDS <- 8
N_POSITION_UUIDS <- N_JOB_UUIDS + 13
jobs_guids <- UUIDgenerate(n = N_JOB_UUIDS)
employee_guids <- UUIDgenerate(n = N_EMPLOYEE_UUIDS)
company_guids <- UUIDgenerate(n = N_COMPANY_UUIDS)
position_guids <- UUIDgenerate(n = N_POSITION_UUIDS)
# #######################################################
# Build the employees table
# #######################################################
employees <- tibble(
guid = employee_guids,
state = sample(
c("CA", "FL", "NY", "TX"),
length(employee_guids),
replace = TRUE),
status = sample(
1:3,
length(employee_guids),
replace = TRUE)
)
employees1 <- employees %>%
mutate(guid = paste0("{", guid, "}", sep = ""))
write.csv(as.data.frame(employees1), here("./data/employees.csv"), row.names = FALSE)
# #######################################################
# Build the jobs table
# #######################################################
jobs <- tibble(
guid = jobs_guids,
company_guid = sample(
company_guids,
size = N_JOB_UUIDS,
replace = TRUE
),
employee_guid = employee_guids
)
jobs1 <- jobs %>%
mutate_all(~ paste0("{", ., "}", sep = ""))
write.csv(as.data.frame(jobs1), here("./data/jobs.csv"), row.names = FALSE)
# #######################################################
# Build the companies table
# #######################################################
companies <- tibble(
guid = company_guids
)
companies$name <- paste("Company Name", 1:nrow(companies))
companies$status <- sample(1:3, nrow(companies), replace = TRUE)
companies1 <- companies %>%
mutate(guid = paste0("{", guid, "}", sep = ""))
write.csv(as.data.frame(companies1), here("./data/companies.csv"), row.names = FALSE)
# #######################################################
# Build the positions table
# #######################################################
positions <- tibble(
guid = position_guids
)
positions$name <- paste("Position", 1:nrow(positions))
positions$status <- sample(1:3, nrow(positions), replace = TRUE)
positions1 <- positions %>%
mutate(guid = paste0("{", guid, "}", sep = ""))
write.csv(as.data.frame(positions), here("./data/positions.csv"), row.names = FALSE)