forked from Jesiara/Database-Lab-Exam
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlabtest_a1.html
More file actions
351 lines (305 loc) · 8.63 KB
/
labtest_a1.html
File metadata and controls
351 lines (305 loc) · 8.63 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Lab Test 01</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
h1,
h2,
ol,
ul,
p {
margin-top: 20px;
margin-bottom: 10px;
}
h1 {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
h2 {
font-size: 22px;
}
ul {
list-style-type: disc;
margin-left: 30px;
}
ol {
list-style-type: decimal;
margin-left: 30px;
}
li {
margin-bottom: 5px;
}
p {
font-size: 18px;
}
table {
border-collapse: collapse;
border: 2px solid black;
}
th,
td {
border: 1px solid black;
padding: 8px;
text-align: left;
}
th {
background-color: #ddd;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
td:first-child,
th:first-child {
border-left: none;
}
td:last-child,
th:last-child {
border-right: none;
}
body {
font-family: sans-serif;
display: grid;
height: 100vh;
place-items: center;
}
.base-timer {
position: relative;
width: 300px;
height: 300px;
}
.base-timer__svg {
transform: scaleX(-1);
}
.base-timer__circle {
fill: none;
stroke: none;
}
.base-timer__path-elapsed {
stroke-width: 7px;
stroke: grey;
}
.base-timer__path-remaining {
stroke-width: 7px;
stroke-linecap: round;
transform: rotate(90deg);
transform-origin: center;
transition: 1s linear all;
fill-rule: nonzero;
stroke: currentColor;
}
.base-timer__path-remaining.green {
color: rgb(65, 184, 131);
}
.base-timer__path-remaining.orange {
color: orange;
}
.base-timer__path-remaining.red {
color: red;
}
.base-timer__label {
position: absolute;
width: 300px;
height: 300px;
top: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 48px;
}
</style>
</head>
<body>
<h1>CSE 3110: Database Systems Laboratory - Lab Test 01 <br>
Time: 30 min
</h1>
<p>Instruction: <mark>You have to write all the commands in a script file. Save the file using your Roll number (ex. 1907018.sql)</mark></p>
<div style="max-width: 800px; margin: 0 auto;">
<h2>Table Description</h2>
<table class="table table-hover">
<tr>
<th>Table Name</th>
<th>Columns</th>
</tr>
<tr>
<td>Departments</td>
<td>department_id <br> name</td>
</tr>
<tr>
<td>Employees</td>
<td>employee_id<br>first_name<br>last_name<br>email<br>hire_date<br>department_id</td>
</tr>
<tr>
<td>Salaries</td>
<td>employee_id<br>salary<br>from_date<br>to_date</td>
</tr>
</table>
<ul class="list-group">
<li class="list-group-item list-group-item-primary">The Departments table has 2 columns: department_id and
name.
<ul>
<li class="list-group-item list-group-item-secondary">The department_id column is an integer column
that is set as the primary key of the table.</li>
</ul>
</li>
<li class="list-group-item list-group-item-primary">The Employees table has 6 columns: employee_id,
first_name, last_name, email, hire_date, and
department_id.
<ul>
<li class="list-group-item list-group-item-secondary">The employee_id column is an integer column
and is set as the primary key of the table.</li>
<li class="list-group-item list-group-item-secondary">The department_id column is an integer column
that is a foreign key referencing the
department_id column in the Departments table.</li>
</ul>
</li>
<li class="list-group-item list-group-item-primary">The Salaries table has 4 columns: employee_id, salary,
from_date, and to_date.
<ul>
<li class="list-group-item list-group-item-secondary">The employee_id column is an integer column
that is a foreign key referencing the employee_id
column in the Employees table.</li>
<li class="list-group-item list-group-item-secondary">The from_date column is a DATE column that
stores the start date for the salary record. This
column, together with employee_id, forms the primary key of the table.</li>
</ul>
</li>
</ul>
<img src="departments.png" class="img-fluid" alt="Department">
<img src="employees.png" class="img-fluid" alt="Employees">
<img src="salaries.png" class="img-fluid" alt="Salaries">
<h2>Queries</h2>
<ul class="list-group">
<li class="list-group-item list-group-item-action active">Question</li>
<li class="list-group-item">1)Insert above data for each table.</li>
<li class="list-group-item">2)Retrieve the first name, last name, email, department name, and salary of all
employees who work in the Sales department.</li>
<li class="list-group-item">3)Retrieve the average salary of all employees in the company.</li>
<li class="list-group-item">4)Retrieve the name of the department with the highest average salary.</li>
<li class="list-group-item">5)Retrieve the first name, last name, email, and total salary of all employees
hired in 2022.</li>
<li class="list-group-item">6)Retrieve the first name, last name, email, and salary of the employee with the
highest salary.</li>
<li class="list-group-item">7)Retrieve the first name,last name and email of employee which department name
contains with "ng".</li>
</ul>
</div>
<div>
<div id="app"></div>
</div>
<script>
const FULL_DASH_ARRAY = 283;
const WARNING_THRESHOLD = 10;
const ALERT_THRESHOLD = 5;
const COLOR_CODES = {
info: {
color: "green"
},
warning: {
color: "orange",
threshold: WARNING_THRESHOLD
},
alert: {
color: "red",
threshold: ALERT_THRESHOLD
}
};
const TIME_LIMIT = 1800;
let timePassed = 0;
let timeLeft = TIME_LIMIT;
let timerInterval = null;
let remainingPathColor = COLOR_CODES.info.color;
document.getElementById("app").innerHTML = `
<div class="base-timer">
<svg class="base-timer__svg" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<g class="base-timer__circle">
<circle class="base-timer__path-elapsed" cx="50" cy="50" r="45"></circle>
<path
id="base-timer-path-remaining"
stroke-dasharray="283"
class="base-timer__path-remaining ${remainingPathColor}"
d="
M 50, 50
m -45, 0
a 45,45 0 1,0 90,0
a 45,45 0 1,0 -90,0
"
></path>
</g>
</svg>
<span id="base-timer-label" class="base-timer__label">${formatTime(
timeLeft
)}</span>
</div>
`;
startTimer();
function onTimesUp() {
clearInterval(timerInterval);
}
function startTimer() {
timerInterval = setInterval(() => {
timePassed = timePassed += 1;
timeLeft = TIME_LIMIT - timePassed;
document.getElementById("base-timer-label").innerHTML = formatTime(
timeLeft
);
setCircleDasharray();
setRemainingPathColor(timeLeft);
if (timeLeft === 0) {
onTimesUp();
}
}, 1000);
}
function formatTime(time) {
const minutes = Math.floor(time / 60);
let seconds = time % 60;
if (seconds < 10) {
seconds = `0${seconds}`;
}
return `${minutes}:${seconds}`;
}
function setRemainingPathColor(timeLeft) {
const { alert, warning, info } = COLOR_CODES;
if (timeLeft <= alert.threshold) {
document
.getElementById("base-timer-path-remaining")
.classList.remove(warning.color);
document
.getElementById("base-timer-path-remaining")
.classList.add(alert.color);
} else if (timeLeft <= warning.threshold) {
document
.getElementById("base-timer-path-remaining")
.classList.remove(info.color);
document
.getElementById("base-timer-path-remaining")
.classList.add(warning.color);
}
}
function calculateTimeFraction() {
const rawTimeFraction = timeLeft / TIME_LIMIT;
return rawTimeFraction - (1 / TIME_LIMIT) * (1 - rawTimeFraction);
}
function setCircleDasharray() {
const circleDasharray = `${(
calculateTimeFraction() * FULL_DASH_ARRAY
).toFixed(0)} 283`;
document
.getElementById("base-timer-path-remaining")
.setAttribute("stroke-dasharray", circleDasharray);
}
</script>
</body>
</html>