-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackWoman.R
More file actions
152 lines (110 loc) · 6.12 KB
/
HackWoman.R
File metadata and controls
152 lines (110 loc) · 6.12 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#SCRIPT: CREATE RELATIONAL DATABASE TO BE USED IN OUR PLATAFORM
#Loading necessary libraries
#Observation: if not installed, please run the following by "un-commenting" it
#install.packages(c("DBI","RSQLite"))
packages <- c("DBI","RSQLite")
lapply(packages, require, character.only = TRUE)
#Creating a database shell
con <- dbConnect(RSQLite::SQLite(), dbname = "db_ff.db")
#Adding columns and rows to our operational table ("users") in a star schema database
rs <- dbSendQuery(conn = con, "CREATE TABLE IF NOT EXISTS users
(
id INTEGER PRIMARY KEY,
email CHAR(40) NOT NULL UNIQUE,
password CHAR(40) NOT NULL,
photo BLOB NULL,
linkedin BLOB NULL,
portifolio BLOB NULL,
name CHAR(60) NOT NULL,
birthday DATE NOT NULL,
description CHAR(250) NULL,
career_id INTEGER NOT NULL,
learn_id INTEGER NOT NULL,
instruct_id INTEGER NOT NULL,
profile_id INTEGER NOT NULL UNIQUE
)")
#Freeing all resources (local and remote) associated with a result set
dbClearResult(rs)
#Creating another table ("careers") connected to "users" table
rs2 <- dbSendQuery(conn = con, "CREATE TABLE IF NOT EXISTS careers
(
career_id INTEGER PRIMARY KEY,
categories CHAR(40) NOT NULL,
FOREIGN KEY (categories)
REFERENCES users (id)
ON UPDATE CASCADE
ON DELETE SET NULL
)")
#Freeing all resources (local and remote) associated with a result set
dbClearResult(rs2)
#Creating another table ("learns") connected to "users" table
rs3 <- dbSendQuery(conn = con, "CREATE TABLE IF NOT EXISTS learns
(
learn_id INTEGER PRIMARY KEY,
categories CHAR(40) NOT NULL,
FOREIGN KEY (categories)
REFERENCES users (id)
ON UPDATE CASCADE
ON DELETE SET NULL
)")
#Freeing all resources (local and remote) associated with a result set
dbClearResult(rs3)
#Creating another table ("instructs") connected to "users" table
rs4 <- dbSendQuery(conn = con, "CREATE TABLE IF NOT EXISTS instructs
(
instruct_id INTEGER PRIMARY KEY,
categories CHAR(40) NOT NULL,
FOREIGN KEY (categories)
REFERENCES users (id)
ON UPDATE CASCADE
ON DELETE SET NULL
)")
#Freeing all resources (local and remote) associated with a result set
dbClearResult(rs4)
#Creating another table ("profiles") connected to "users" table
rs5 <- dbSendQuery(conn = con, "CREATE TABLE IF NOT EXISTS profiles
(
profile_id INTEGER PRIMARY KEY,
other CHAR(40) NOT NULL,
FOREIGN KEY (other)
REFERENCES users (id)
ON UPDATE CASCADE
ON DELETE SET NULL
)")
#Freeing all resources (local and remote) associated with a result set
dbClearResult(rs5)
#Filling Careers Table
dbSendQuery(conn = con,"INSERT INTO careers (career_id, categories)
VALUES(1, 'Produto')")
dbSendQuery(conn = con,"INSERT INTO careers (career_id, categories)
VALUES(2, 'Desenvolvimento')")
dbSendQuery(conn = con,"INSERT INTO careers (career_id, categories)
VALUES(3, 'Design')")
dbSendQuery(conn = con,"INSERT INTO careers (career_id, categories)
VALUES(4, 'Liderança')")
dbSendQuery(conn = con,"INSERT INTO careers (career_id, categories)
VALUES(5, 'Data')")
#Filling Learns Table
dbSendQuery(conn = con,"INSERT INTO learns (learn_id, categories)
VALUES(1, 'Revisão de Currículo')")
dbSendQuery(conn = con,"INSERT INTO learns (learn_id, categories)
VALUES(2, 'Revisão de Portifólio')")
dbSendQuery(conn = con,"INSERT INTO learns (learn_id, categories)
VALUES(3, 'Simulação de Entrevista')")
dbSendQuery(conn = con,"INSERT INTO learns (learn_id, categories)
VALUES(4, 'Conversa sobre Carreira')")
dbSendQuery(conn = con,"INSERT INTO learns (learn_id, categories)
VALUES(5, 'Ajuda Técnica')")
#Filling Instructs Table
dbSendQuery(conn = con,"INSERT INTO instructs (instruct_id, categories)
VALUES(1, 'Revisão de Currículo')")
dbSendQuery(conn = con,"INSERT INTO instructs (instruct_id, categories)
VALUES(2, 'Revisão de Portifólio')")
dbSendQuery(conn = con,"INSERT INTO instructs (instruct_id, categories)
VALUES(3, 'Simulação de Entrevista')")
dbSendQuery(conn = con,"INSERT INTO instructs (instruct_id, categories)
VALUES(4, 'Conversa sobre Carreira')")
dbSendQuery(conn = con,"INSERT INTO instructs (instruct_id, categories)
VALUES(5, 'Ajuda Técnica')")
#Disconnecting from db
dbDisconnect(con)