This repository was archived by the owner on Mar 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.xml
723 lines (561 loc) · 39.5 KB
/
index.xml
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>TP's School Site</title>
<link>https://web.cs.sunyit.edu/~pereztr/</link>
<description>Recent content on TP's School Site</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<lastBuildDate>Tue, 26 Apr 2016 05:25:43 -0400</lastBuildDate>
<atom:link href="https://web.cs.sunyit.edu/~pereztr/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Main</title>
<link>https://web.cs.sunyit.edu/~pereztr/1/</link>
<pubDate>Tue, 26 Apr 2016 05:25:43 -0400</pubDate>
<guid>https://web.cs.sunyit.edu/~pereztr/1/</guid>
<description>
<h3 id="home:d680e8a854a7cbad6d490c445cba2eba">Home</h3>
<h2 id="school-documention:d680e8a854a7cbad6d490c445cba2eba">School Documention</h2>
<p>Lorem ipsum</p>
</description>
</item>
<item>
<title>CS350</title>
<link>https://web.cs.sunyit.edu/~pereztr/cs350/</link>
<pubDate>Tue, 26 Apr 2016 16:46:45 -0400</pubDate>
<guid>https://web.cs.sunyit.edu/~pereztr/cs350/</guid>
<description>
<h3 id="information-and-knowledge-management:d680e8a854a7cbad6d490c445cba2eba">Information and Knowledge Management</h3>
<h1 id="cs350:d680e8a854a7cbad6d490c445cba2eba">CS350</h1>
<p>Lorem ipsum</p>
</description>
</item>
<item>
<title>Homework 2</title>
<link>https://web.cs.sunyit.edu/~pereztr/cs350/hw2/</link>
<pubDate>Tue, 26 Apr 2016 22:43:06 -0400</pubDate>
<guid>https://web.cs.sunyit.edu/~pereztr/cs350/hw2/</guid>
<description>
<h4 id="3-19:d680e8a854a7cbad6d490c445cba2eba">3.19</h4>
<p>Consider a STUDENT relation in a UNIVERSITY database with the following attributes
(Name, Ssn, Local_phone, Address, Cell_phone, Age, Gpa). Note that the cell phone
may be from a different city and state (or province) from the local phone.
A possible tuple of the relation is shown below:
<img src="https://web.cs.sunyit.edu/~pereztr/~pereztr/images/cs350hw2.png" alt="text" /></p>
<p><strong>a</strong>. <em>Q</em>: Identify the critical missing information from the Local_phone and Cell_phone attributes.
(Hint: How do you call someone who lives in a different state or province?)</p>
<p><em>A</em>: The critical missing information is the country code and aarea code.</p>
<p><strong>b</strong>. <em>Q</em>: Would you store this additional information in the Local_phone and Cell_phone
attributes or add new attributes to the schema for STUDENT?</p>
<p><em>A</em>: I would store this in the <code>Local_phone</code> and <code>Cell_phone</code> attribute.</p>
<p><strong>c</strong>. <em>Q</em>: Consider the Name attribute. What are the advantages and disadvantages of splitting
this field from one attribute into three attributes (first name, middle name, and last name)?</p>
<p><em>A</em>: The advatages are that it would be easier to index and look up.
Better queries can also be created. The disadvantages are that if you
already have the name saved into one attribute it would take some time
to go through every row and split them up.</p>
<p><strong>d</strong>. <em>Q</em>: What general guide line would you recommend for deciding when to store information in a single attribute and when to split the information?</p>
<p><em>A</em>:I would first think about if this information can be used to group certain rows.</p>
<p><strong>e</strong>. <em>Q</em>: Suppose the student can have between 0 and 5 phones.
Suggest two different designs that allow this type of information.</p>
<p><em>A</em>: If you know the student can have multiple phone numbers you can have another table that relates to the student and it could have 0 or more.</p>
<hr />
<h4 id="4-12:d680e8a854a7cbad6d490c445cba2eba">4.12</h4>
<p>Specify the following queries in SQL on the database schema of Figure 1.2.
<img src="https://web.cs.sunyit.edu/~pereztr/~pereztr/images/cs350fig12.png" alt="fig12" />
<em>Figure 1.2</em></p>
<p><strong>a</strong>. Retrieve the names of all senior students majoring in ‘CS’ (computer sci- ence).</p>
<pre><code>SELECT Name
FROM STUDENT
WHERE Class=4
AND Major='CS';
</code></pre>
<p><strong>b</strong>. Retrieve the names of all courses taught by Professor King in 2007 and 2008.</p>
<pre><code>SELECT COURSE.Course_name
FROM COURSE, SECTION
WHERE COURSE.Course_number=SECTION.Course_number
AND Instructor='King'
AND (Year='07' OR Year='08');
</code></pre>
<p><strong>c</strong>. For each section taught by Professor King, retrieve the course number, semester, year, and number of students who took the section.</p>
<pre><code>SELECT SECTION.Course_number, SECTION.Semester, SECTION.Year, GRADE_REPORT.Student_number
FROM SECTION, GRADE_REPORT
WHERE SECTION.Instructor='King'
AND GRADE_REPORT.Section_identifier=SECTION.Section_identifier;
</code></pre>
<p><strong>d</strong>. Retrieve the name and transcript of each senior student (Class = 4) majoring in CS. A transcript includes course name, course number, credit hours, semester, year, and grade for each course completed by the student.</p>
<pre><code>SELECT STUDENT.Name , COURSE.Course_name,
COURSE.Course_number, COURSE.Credit_hours,
SECTION.Semester, SECTION.Year, GRADE_REPORT.Grade
FROM STUDENT, COURSE, SECTION, GRADE_REPORT
WHERE STUDENT.Student_number=GRADE_REPORT.Student_number
AND SECTION.Section_identifier=GRADE_REPORT.Section_identifier
AND SECTION.Course_number=COURSE.Course_number;
</code></pre>
</description>
</item>
<item>
<title>Homework 4</title>
<link>https://web.cs.sunyit.edu/~pereztr/cs350/hw4/</link>
<pubDate>Wed, 27 Apr 2016 00:59:08 -0400</pubDate>
<guid>https://web.cs.sunyit.edu/~pereztr/cs350/hw4/</guid>
<description>
<h4 id="5-6:d680e8a854a7cbad6d490c445cba2eba">5.6</h4>
<p><strong>a</strong>. Retrieve the names and major departments of all straight-A students (students who have a grade of A in all their courses).</p>
<pre><code>SELECT STUDENT.Name, STUDENT.Major
FROM STUDENT
WHERE NOT EXISTS (
SELECT * FROM GRADE_REPORT
WHERE GRADE_REPORT.Student_number = STUDENT.Student_number
AND GRADE &lt;&gt; &quot;A&quot;
);
</code></pre>
<p><strong>b</strong>. Retrieve the names and major departments of all students who do not have a grade of A in any of their courses.</p>
<pre><code>SELECT STUDENT.Name, STUDENT.Major
FROM STUDENT
WHERE NOT EXISTS (
SELECT * FROM GRADE_REPORT
WHERE GRADE_REPORT.Student_number = STUDENT.Student_number
AND GRADE = &quot;A&quot;
);
</code></pre>
<hr />
<h4 id="5-7:d680e8a854a7cbad6d490c445cba2eba">5.7</h4>
<p><strong>a</strong>. Retrieve the names of all employees who work in the department that has the employee with the highest salary among all employees.</p>
<pre><code>SELECT e.Fname, e.Lname, e.Dno, e.Salary
FROM Employee e
LEFT JOIN employee b
ON e.Dno = b.Dno AND e.Salary &lt; b.Salary
WHERE b.Salary is NULL;
</code></pre>
<p><strong>b</strong>. Retrieve the names of all employees whose supervisor’s supervisor has ‘888665555’ for Ssn.</p>
<pre><code>SELECT Employee.Fname, Employee.Lname
FROM Employee
WHERE superssn = &quot;888665555&quot;;
</code></pre>
</description>
</item>
<item>
<title>Homework 5</title>
<link>https://web.cs.sunyit.edu/~pereztr/cs350/hw5/</link>
<pubDate>Wed, 27 Apr 2016 03:10:56 -0400</pubDate>
<guid>https://web.cs.sunyit.edu/~pereztr/cs350/hw5/</guid>
<description>
<h4 id="6-23:d680e8a854a7cbad6d490c445cba2eba">6.23</h4>
<p>Specify the following queries in relational algebra on the database schema in Exercise 3.17:
<img src="https://web.cs.sunyit.edu/~pereztr/~pereztr/images/cs350hw5.png" alt="ex317" /></p>
<p><strong>a</strong>. For the salesperson named ‘Jane Doe’, list the following information for all the cars she sold: Serial#, Manufacturer, Sale_price.</p>
<p><strong>b</strong>. List the Serial# and Model of cars that have no options.</p>
<p><strong>c</strong>. Consider the NATURAL JOIN operation between SALESPERSON and SALE. What is the meaning of a left outer join for these tables (do not change the order of relations)? Explain with an example.</p>
<p><strong>d</strong>. Write a query in relational algebra involving selection and one set opera- tion and say in words what the query does.</p>
<hr />
<h4 id="6-26:d680e8a854a7cbad6d490c445cba2eba">6.26</h4>
<p>Specify queries c, d, and f of Exercise 6.18 in both tuple and domain relational
calculus.</p>
</description>
</item>
<item>
<title>Homework 6</title>
<link>https://web.cs.sunyit.edu/~pereztr/cs350/hw6/</link>
<pubDate>Wed, 27 Apr 2016 03:57:13 -0400</pubDate>
<guid>https://web.cs.sunyit.edu/~pereztr/cs350/hw6/</guid>
<description>
<h4 id="7-19:d680e8a854a7cbad6d490c445cba2eba">7.19</h4>
<p>Consider the ER diagram in Figure 7.20, which shows a simplified schema for an
airline reservations system. Extract from the ER diagram the requirements and
constraints that produced this schema. Try to be as precise as possible in your
requirements and constraints specification.
<img src="https://web.cs.sunyit.edu/~pereztr/~pereztr/images/cs350fig720.png" alt="fig710" /></p>
<hr />
<h4 id="8-29:d680e8a854a7cbad6d490c445cba2eba">8.29</h4>
<p>Consideran ONLINE_AUCTION database system in which members(buyers and sellers)
participate in the sale of items. The data requirements for this system are
summarized as follows:</p>
<ul>
<li><p>The online site has members, each of whom is identified by a unique member number
and is described by an e-mail address, name, password, home address, and phone number.</p></li>
<li><p>A member may be a buyer or a seller. A buyer has a shipping address recorded in the
database. A seller has a bank account number and routing number recorded in the
database.</p></li>
<li><p>Items are placed by a seller for sale and are identified by a unique item number
assigned by the system. Items are also described by an item title, a description,
starting bid price, bidding increment, the start date of the auction, and the end
date of the auction.</p></li>
<li><p>Items are also categorized based on a fixed classification hierarchy (for example,
a modem may be classified as COMPUTER→HARDWARE →MODEM).</p></li>
<li><p>Buyers make bids for items they are interested in. Bid price and time of bid is
recorded. The bidder at the end of the auction with the highest bid price is
declared the winner and a transaction between buyer and seller may then proceed.</p></li>
<li><p>The buyer and seller may record feedback regarding their completed transactions.
Feedback contains a rating of the other party participating in the transaction (1–10)
and a comment.</p></li>
</ul>
<p>Design an Enhanced Entity-Relationship diagram for the ONLINE_AUCTION database and build the design using a data modeling tool such as ERwin or Rational Rose.</p>
</description>
</item>
<item>
<title>Homework 8</title>
<link>https://web.cs.sunyit.edu/~pereztr/cs350/hw8/</link>
<pubDate>Wed, 27 Apr 2016 04:04:07 -0400</pubDate>
<guid>https://web.cs.sunyit.edu/~pereztr/cs350/hw8/</guid>
<description>
<h4 id="17-41:d680e8a854a7cbad6d490c445cba2eba">17.41</h4>
<p>Write program code to access individual fields of records under each of the following
circumstances. For each case, state the assumptions you make con- cerning pointers,
separator characters, and so on. Determine the type of information needed in the file
header in order for your code to be general in each case.</p>
<p><strong>a</strong>. Fixed-length records with unspanned blocking</p>
<p><strong>b</strong>. Fixed-length records with spanned blocking</p>
<p><strong>c</strong>. Variable-length records with variable-length fields and spanned blocking</p>
<p><strong>d</strong>. Variable-length records with repeating groups and spanned blocking</p>
<p><strong>e</strong>. Variable-length records with optional fields and spanned blocking</p>
<p><strong>f</strong>. Variable-length records that allow all three cases in parts c, d, and e</p>
<hr />
<h4 id="18-19:d680e8a854a7cbad6d490c445cba2eba">18.19</h4>
<p>A PARTS file with Part# as the key field includes records with the following Part#
values: 23, 65, 37, 60, 46, 92, 48, 71, 56, 59, 18, 21, 10, 74, 78, 15, 16, 20, 24,
28, 39, 43, 47, 50, 69, 75, 8, 49, 33, 38. Suppose that the search field values are
inserted in the given order in a B+-tree of order p = 4 and pleaf = 3; show how the
tree will expand and what the final tree will look like.</p>
</description>
</item>
<item>
<title>Mini Project</title>
<link>https://web.cs.sunyit.edu/~pereztr/cs350/miniproject/</link>
<pubDate>Tue, 26 Apr 2016 17:59:46 -0400</pubDate>
<guid>https://web.cs.sunyit.edu/~pereztr/cs350/miniproject/</guid>
<description>
<h2 id="cyboard-queries:d680e8a854a7cbad6d490c445cba2eba">Cyboard Queries</h2>
<p>Here are the queries I used in my Cyboard project<br />
Project is on <a href="https://github.com/pereztr5/cyboard">Github</a></p>
<h3 id="aggregation:d680e8a854a7cbad6d490c445cba2eba">Aggregation</h3>
<h5 id="get-service-and-the-last-status-for-that-team:d680e8a854a7cbad6d490c445cba2eba">Get service and the last status for that team</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$match&quot;: {&quot;type&quot;: &quot;Service&quot;}},
{&quot;$group&quot;:
{
&quot;_id&quot;: {&quot;type&quot;: &quot;$group&quot;, &quot;tnumber&quot;: &quot;$teamnumber&quot;, &quot;tname&quot;: &quot;$teamname&quot;},
&quot;status&quot;: {&quot;$last&quot;: &quot;$details&quot;}
}
},
{&quot;$group&quot;:
{
&quot;_id&quot;: &quot;$_id.type&quot;,
&quot;teams&quot;: {&quot;$addToSet&quot;: {&quot;teamnumber&quot;: &quot;$_id.teamnumber&quot;, &quot;teamname&quot;: &quot;$_id.tname&quot;, &quot;status&quot;: &quot;$status&quot;}}
}
}
)
</code></pre>
<p>Result</p>
<pre><code>[{
&quot;_id&quot; : &quot;WWW 80&quot;,
&quot;teams&quot; : [
{
&quot;teamname&quot; : &quot;team1&quot;,
&quot;status&quot; : &quot;Status: 2&quot;
},
{
&quot;teamname&quot; : &quot;team4&quot;,
&quot;status&quot; : &quot;Status: 2&quot;
},
{
&quot;teamname&quot; : &quot;team7&quot;,
&quot;status&quot; : &quot;Status: 2&quot;
},
...
]
}, {
&quot;_id&quot; : &quot;WWW SSH&quot;,
&quot;teams&quot; : [
{
&quot;teamname&quot; : &quot;team7&quot;,
&quot;status&quot; : &quot;Status: 2&quot;
},
{
&quot;teamname&quot; : &quot;team1&quot;,
&quot;status&quot; : &quot;Status: 2&quot;
},
...
]
},
...
}]
</code></pre>
<h5 id="same-as-above-except-there-is-no-nested-object:d680e8a854a7cbad6d490c445cba2eba">Same as above except there is no nested object</h5>
<p>NOTE: Sort doesn&rsquo;t always sort for some reason in Go
Query</p>
<pre><code>db.results.aggregate(
{&quot;$match&quot;: {&quot;type&quot;: &quot;Service&quot;}},
{&quot;$group&quot;:
{
&quot;_id&quot;: {&quot;type&quot;: &quot;$group&quot;, &quot;tnumber&quot;: &quot;$teamnumber&quot;, &quot;tname&quot;: &quot;$teamname&quot;},
&quot;status&quot;: {&quot;$last&quot;: &quot;$details&quot;}}
},
{&quot;$group&quot;:
{
&quot;_id&quot;: &quot;$_id.type&quot;,
&quot;teams&quot;: {&quot;$addToSet&quot;: {&quot;number&quot;: &quot;$_id.tnumber&quot;, &quot;name&quot;: &quot;$_id.tname&quot;, &quot;status&quot;: &quot;$status&quot;}}
}
},
{&quot;$unwind&quot;: &quot;$teams&quot;},
{&quot;$project&quot;: {&quot;_id&quot;: 0, &quot;group&quot;: &quot;$_id&quot;, &quot;tnum&quot;: &quot;$teams.number&quot;, &quot;tname&quot;: &quot;$teams.name&quot;, &quot;status&quot;: &quot;$teams.status&quot;}},
{&quot;$sort&quot;: {&quot;tnum&quot;: 1, &quot;group&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 1, &quot;tname&quot; : &quot;team1&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 2, &quot;tname&quot; : &quot;team2&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 3, &quot;tname&quot; : &quot;team3&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 4, &quot;tname&quot; : &quot;team4&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 5, &quot;tname&quot; : &quot;team5&quot;, &quot;status&quot; : &quot;Status: 1&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 6, &quot;tname&quot; : &quot;team6&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 7, &quot;tname&quot; : &quot;team7&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 8, &quot;tname&quot; : &quot;team8&quot;, &quot;status&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 9, &quot;tname&quot; : &quot;team9&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot;, &quot;tnum&quot; : 10, &quot;tname&quot; : &quot;team10&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 1, &quot;tname&quot; : &quot;team1&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 2, &quot;tname&quot; : &quot;team2&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 3, &quot;tname&quot; : &quot;team3&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 4, &quot;tname&quot; : &quot;team4&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 5, &quot;tname&quot; : &quot;team5&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 6, &quot;tname&quot; : &quot;team6&quot;, &quot;status&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 7, &quot;tname&quot; : &quot;team7&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 8, &quot;tname&quot; : &quot;team8&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 9, &quot;tname&quot; : &quot;team9&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot;, &quot;tnum&quot; : 10, &quot;tname&quot; : &quot;team10&quot;, &quot;status&quot; : &quot;Status: 2&quot; }
...
</code></pre>
<h5 id="get-service-list-form-results:d680e8a854a7cbad6d490c445cba2eba">Get service list form results</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$match&quot;: {&quot;type&quot;: &quot;Service&quot;}},
{&quot;$group&quot;: {&quot;_id&quot;: &quot;$group&quot;}},
{&quot;$project&quot;: {&quot;_id&quot;: 0, &quot;group&quot;: &quot;$_id&quot;}}
)
</code></pre>
<p>Results</p>
<pre><code>{ &quot;group&quot; : &quot;WWW SSH&quot; }
{ &quot;group&quot; : &quot;MAIL POP&quot; }
{ &quot;group&quot; : &quot;MAIL SMTP&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot; }
{ &quot;group&quot; : &quot;WWW 80&quot; }
</code></pre>
<h5 id="get-ctf-list-form-results:d680e8a854a7cbad6d490c445cba2eba">Get CTF list form results</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$match&quot;: {&quot;type&quot;: &quot;CTF&quot;}},
{&quot;$group&quot;: {&quot;_id&quot;: &quot;$group&quot;}},
{&quot;$project&quot;: {&quot;_id&quot;: 0, &quot;group&quot;: &quot;$_id&quot;}}
)
</code></pre>
<p>Results</p>
<pre><code>{ &quot;group&quot; : &quot;Misc-Enumeration&quot; }
{ &quot;group&quot; : &quot;Rusted Bunions&quot; }
{ &quot;group&quot; : &quot;SIGNUP&quot; }
{ &quot;group&quot; : &quot;CTF-Web&quot; }
</code></pre>
<h5 id="group-by-challenge-and-get-the-total-amount-of-challenge-and-the-total-points:d680e8a854a7cbad6d490c445cba2eba">Group by challenge and get the total amount of challenge and the total points</h5>
<p>Query</p>
<pre><code>db.challenges.aggregate(
{&quot;$group&quot;:
{
&quot;_id&quot;: &quot;$group&quot;,
&quot;total challenges&quot;: {&quot;$sum&quot;: 1},
&quot;total points&quot;: {&quot;$sum&quot;: &quot;$points&quot;}
}
},
{&quot;$sort&quot;: {&quot;_id&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;_id&quot; : &quot;CTF-Web&quot;, &quot;total challenges&quot; : 16, &quot;total points&quot; : 100 }
{ &quot;_id&quot; : &quot;CentOS&quot;, &quot;total challenges&quot; : 3, &quot;total points&quot; : 40 }
{ &quot;_id&quot; : &quot;Misc-Enumeration&quot;, &quot;total challenges&quot; : 100, &quot;total points&quot; : 100 }
{ &quot;_id&quot; : &quot;Rusted Bunions&quot;, &quot;total challenges&quot; : 7, &quot;total points&quot; : 395 }
{ &quot;_id&quot; : &quot;SIGNUP&quot;, &quot;total challenges&quot; : 2, &quot;total points&quot; : 3 }
{ &quot;_id&quot; : &quot;Win-XP&quot;, &quot;total challenges&quot; : 7, &quot;total points&quot; : 65 }
</code></pre>
<h5 id="get-the-amount-of-challenges-a-certain-team-obtained:d680e8a854a7cbad6d490c445cba2eba">Get the amount of challenges a certain team obtained</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$match&quot;: {&quot;teamname&quot;: &quot;team1&quot;, &quot;type&quot;: &quot;CTF&quot;}},
{&quot;$group&quot;: {&quot;_id&quot;: &quot;$group&quot;, &quot;acquired&quot;: {&quot;$sum&quot;: 1}}},
{&quot;$sort&quot;: {&quot;_id&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;_id&quot; : &quot;Rusted Bunions&quot;, &quot;acquired&quot; : 2 }
{ &quot;_id&quot; : &quot;SIGNUP&quot;, &quot;acquired&quot; : 1 }
</code></pre>
<h5 id="same-as-above-except-with-the-total-points:d680e8a854a7cbad6d490c445cba2eba">Same as above except with the total points</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$match&quot;: {&quot;teamname&quot;: &quot;team10&quot;, &quot;type&quot;: &quot;CTF&quot;}},
{&quot;$group&quot;: {&quot;_id&quot;: &quot;$group&quot;, &quot;acquired&quot;: {&quot;$sum&quot;: 1}}},
{&quot;$sort&quot;: {&quot;_id&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;_id&quot; : &quot;Misc-Enumeration&quot;, &quot;acquired&quot; : 8, &quot;points&quot; : 8 }
{ &quot;_id&quot; : &quot;Rusted Bunions&quot;, &quot;acquired&quot; : 4, &quot;points&quot; : 125 }
{ &quot;_id&quot; : &quot;SIGNUP&quot;, &quot;acquired&quot; : 2, &quot;points&quot; : 3 }
</code></pre>
<h5 id="get-a-team-score-and-only-output-the-points:d680e8a854a7cbad6d490c445cba2eba">Get a team score and only output the points</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$match&quot;: {&quot;teamname&quot;: &quot;team3&quot;}},
{&quot;$group&quot;:
{
&quot;_id&quot;: null,
&quot;points&quot;: {&quot;$sum&quot;: &quot;$points&quot;}
}
},
{&quot;$project&quot;: {&quot;_id&quot;: 0, &quot;points&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;points&quot; : 758 }
</code></pre>
<h5 id="get-all-team-scores:d680e8a854a7cbad6d490c445cba2eba">Get all team scores</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$group&quot;:
{
&quot;_id&quot;: {&quot;tname&quot;: &quot;$teamname&quot;, &quot;tnum&quot;: &quot;$teamnumber&quot;},
&quot;points&quot;: {&quot;$sum&quot;: &quot;$points&quot;}
}
},
{&quot;$project&quot;:
{
&quot;_id&quot;: 0,
&quot;points&quot;: 1,
&quot;teamnumber&quot;: &quot;$_id.tnum&quot;,
&quot;teamname&quot;: &quot;$_id.tname&quot;
}
},
{&quot;$sort&quot;: {&quot;teamnumber&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;points&quot; : 485, &quot;teamnumber&quot; : 1, &quot;teamname&quot; : &quot;team1&quot; }
{ &quot;points&quot; : 558, &quot;teamnumber&quot; : 2, &quot;teamname&quot; : &quot;team2&quot; }
{ &quot;points&quot; : 758, &quot;teamnumber&quot; : 3, &quot;teamname&quot; : &quot;team3&quot; }
{ &quot;points&quot; : 691, &quot;teamnumber&quot; : 4, &quot;teamname&quot; : &quot;team4&quot; }
{ &quot;points&quot; : 512, &quot;teamnumber&quot; : 5, &quot;teamname&quot; : &quot;team5&quot; }
{ &quot;points&quot; : 649, &quot;teamnumber&quot; : 6, &quot;teamname&quot; : &quot;team6&quot; }
{ &quot;points&quot; : 497, &quot;teamnumber&quot; : 7, &quot;teamname&quot; : &quot;team7&quot; }
{ &quot;points&quot; : 502, &quot;teamnumber&quot; : 8, &quot;teamname&quot; : &quot;team8&quot; }
{ &quot;points&quot; : 379, &quot;teamnumber&quot; : 9, &quot;teamname&quot; : &quot;team9&quot; }
{ &quot;points&quot; : 459, &quot;teamnumber&quot; : 10, &quot;teamname&quot; : &quot;team10&quot; }
</code></pre>
<h5 id="get-last-status-of-each-team-by-service:d680e8a854a7cbad6d490c445cba2eba">Get last status of each team by service</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$match&quot;: {&quot;type&quot;: &quot;Service&quot;, &quot;group&quot;: &quot;ROUTER PING&quot;}},
{&quot;$group&quot;:
{
&quot;_id&quot;: {&quot;service&quot;: &quot;$group&quot;, &quot;tnum&quot;: &quot;$teamnumber&quot;, &quot;tname&quot;: &quot;$teamname&quot;},
&quot;status&quot;: {&quot;$last&quot;: &quot;$details&quot;}
}
},
{&quot;$project&quot;:
{
&quot;_id&quot;: 0,
&quot;group&quot;: &quot;$_id.service&quot;,
&quot;teamnumber&quot;: &quot;$_id.tnum&quot;,
&quot;teamname&quot;: &quot;$_id.tname&quot;,
&quot;details&quot;: &quot;$status&quot;
}
},
{&quot;$sort&quot;: {&quot;teamnumber&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 1, &quot;teamname&quot; : &quot;team1&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 2, &quot;teamname&quot; : &quot;team2&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 3, &quot;teamname&quot; : &quot;team3&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 4, &quot;teamname&quot; : &quot;team4&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 5, &quot;teamname&quot; : &quot;team5&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 6, &quot;teamname&quot; : &quot;team6&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 7, &quot;teamname&quot; : &quot;team7&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 8, &quot;teamname&quot; : &quot;team8&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 9, &quot;teamname&quot; : &quot;team9&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
{ &quot;group&quot; : &quot;ROUTER PING&quot;, &quot;teamnumber&quot; : 10, &quot;teamname&quot; : &quot;team10&quot;, &quot;details&quot; : &quot;Status: 0&quot; }
</code></pre>
<h5 id="get-the-objectid-of-the-last-document-in-results:d680e8a854a7cbad6d490c445cba2eba">Get the ObjectID of the last document in results</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$sort&quot;: {&quot;_id&quot;: 1}},
{&quot;$group&quot;: {&quot;_id&quot;: null, &quot;last&quot;: {&quot;$last&quot;: &quot;$_id&quot;}}},
{&quot;$project&quot;: {&quot;_id&quot;: 0, &quot;last&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;last&quot; : ObjectId(&quot;571be338afbeb9566a40683d&quot;) }
</code></pre>
<h5 id="get-the-objectid-of-the-last-document-that-is-type-service-in-results:d680e8a854a7cbad6d490c445cba2eba">Get the ObjectID of the last document that is type &ldquo;Service&rdquo; in results</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$match&quot;: {&quot;type&quot;: &quot;Service&quot;}},
{&quot;$sort&quot;: {&quot;_id&quot;: 1}},
{&quot;$group&quot;: {&quot;_id&quot;: null, &quot;last&quot;: {&quot;$last&quot;: &quot;$_id&quot;}}},
{&quot;$project&quot;: {&quot;_id&quot;: 0, &quot;last&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;last&quot; : ObjectId(&quot;571be265afbeb9566a406839&quot;) }
</code></pre>
<h5 id="get-the-amount-of-documents-grouped-by-group:d680e8a854a7cbad6d490c445cba2eba">Get the amount of documents grouped by group</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$group&quot;:
{
&quot;_id&quot;: &quot;$group&quot;,
&quot;total&quot;: {&quot;$sum&quot;: 1}
}
},
{&quot;$sort&quot;: {&quot;_id&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;_id&quot; : &quot;CTF-Web&quot;, &quot;total&quot; : 13 }
{ &quot;_id&quot; : &quot;Extra&quot;, &quot;total&quot; : 1 }
{ &quot;_id&quot; : &quot;MAIL POP&quot;, &quot;total&quot; : 1173 }
{ &quot;_id&quot; : &quot;MAIL SMTP&quot;, &quot;total&quot; : 1171 }
{ &quot;_id&quot; : &quot;Misc-Enumeration&quot;, &quot;total&quot; : 28 }
{ &quot;_id&quot; : &quot;ROUTER PING&quot;, &quot;total&quot; : 1279 }
{ &quot;_id&quot; : &quot;Rusted Bunions&quot;, &quot;total&quot; : 31 }
{ &quot;_id&quot; : &quot;SIGNUP&quot;, &quot;total&quot; : 17 }
{ &quot;_id&quot; : &quot;WWW 80&quot;, &quot;total&quot; : 1271 }
{ &quot;_id&quot; : &quot;WWW SSH&quot;, &quot;total&quot; : 1174 }
</code></pre>
<h5 id="same-as-above-except-with-total-points:d680e8a854a7cbad6d490c445cba2eba">Same as above except with total points</h5>
<p>Query</p>
<pre><code>db.results.aggregate(
{&quot;$group&quot;:
{
&quot;_id&quot;: &quot;$group&quot;,
&quot;total&quot;: {&quot;$sum&quot;: 1},
&quot;points&quot;: {&quot;$sum&quot;: &quot;$points&quot;}
}
},
{&quot;$sort&quot;: {&quot;_id&quot;: 1}}
)
</code></pre>
<p>Result</p>
<pre><code>{ &quot;_id&quot; : &quot;CTF-Web&quot;, &quot;amt&quot; : 13, &quot;points&quot; : 80 }
{ &quot;_id&quot; : &quot;Extra&quot;, &quot;amt&quot; : 1, &quot;points&quot; : 250 }
{ &quot;_id&quot; : &quot;MAIL POP&quot;, &quot;amt&quot; : 1173, &quot;points&quot; : 104 }
{ &quot;_id&quot; : &quot;MAIL SMTP&quot;, &quot;amt&quot; : 1171, &quot;points&quot; : 15 }
{ &quot;_id&quot; : &quot;Misc-Enumeration&quot;, &quot;amt&quot; : 28, &quot;points&quot; : 28 }
{ &quot;_id&quot; : &quot;ROUTER PING&quot;, &quot;amt&quot; : 1279, &quot;points&quot; : 2561 }
{ &quot;_id&quot; : &quot;Rusted Bunions&quot;, &quot;amt&quot; : 31, &quot;points&quot; : 1055 }
{ &quot;_id&quot; : &quot;SIGNUP&quot;, &quot;amt&quot; : 17, &quot;points&quot; : 22 }
{ &quot;_id&quot; : &quot;WWW 80&quot;, &quot;amt&quot; : 1271, &quot;points&quot; : 1057 }
{ &quot;_id&quot; : &quot;WWW SSH&quot;, &quot;amt&quot; : 1174, &quot;points&quot; : 318 }
</code></pre>
</description>
</item>
</channel>
</rss>