-
Notifications
You must be signed in to change notification settings - Fork 0
/
database_slides.qmd
1181 lines (817 loc) · 34.6 KB
/
database_slides.qmd
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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "An Overview of Databases and Data Storage"
title-slide-attributes:
data-background-image: img/slides/datalab-logo-full-color-rgb.png
data-background-size: 35%
data-background-position: 5% 2%
author: "Elise Hellwig"
format:
revealjs:
sc-sb-title: true
theme: simple
template-partials:
- title-slide.html
filters:
- reveal-header
slide-level: 3
editor: source
bibliography: data/references.bib
nocite: '@*'
---
```{r format_cars, echo=FALSE}
makers = c('Mazda', 'Merc', 'Toyota', 'Ferarri', 'Lincoln', 'Chrysler', 'Dodge')
origins = c(rep('Japan', 2), rep('Europe', 7), rep('Japan', 2), rep('USA', 3))
maker_ids = sapply(makers, grep, rownames(mtcars)) |>
unlist(use.names=FALSE) |>
unique()
mpg = mtcars[maker_ids, c('mpg', 'cyl', 'hp', 'wt', 'am')]
rownames(mpg) = gsub('Merc', 'Mercedes-Benz', rownames(mpg))
mpg$origin = origins
names(mpg) = c('mpg', 'cylinders', 'horsepower', 'weight', 'manual', 'origin')
```
# Introduction {background-image="img/slides/trail.png"
background-size="60%"
background-opacity="0.5"}
::: {.notes}
Before we dive in...some info. Not required but helpful for me
to know. Raise your hand if:
- Have data you are working with or are in the process of collecting data
- Analyze data using a programming language like R or Python
- Know what a database is
- Have used a database before
:::
## Research Computing Workshops {background-image="img/slides/trail.png"
background-size="8%" background-opacity="0.9"
background-position="97% 97%"}
<br>
::: {style="font-size: 130%;"}
- Intro to SQL for Querying Databases, 4/23
([[event]{.underline}][sql_event], [[reader]{.underline}][dl_sql])
- Spatial SQL, 5/3 ([[event]{.underline}][spat_event],
[[reader]{.underline}][dl_ssql])
:::
<br>
![](img/slides/datalab-logo-full-color-rgb.png){width="70%" fig-align="center"}
[dl_sql]: https://ucdavisdatalab.github.io/workshop_intro_to_sql/
[dl_ssql]: https://ucdavisdatalab.github.io/Spatial_SQL/
[sql_event]: https://datalab.ucdavis.edu/eventscalendar/workshop-introduction-to-sql-for-querying-databases/
[spat_event]: https://datalab.ucdavis.edu/eventscalendar/workshop-spatial-sql-2/
:::{.notes}
If you decide you want to store your data in database, this would be a good
next step.
:::
## Data Storage Considerations {background-image="img/slides/trail.png"
background-size="8%" background-opacity="0.9"
background-position="97% 97%"}
![](img/data_store_factors.png){width="70%" fig-align="center"}
:::{.notes}
Data store -> method of storing your data.
databases are a type data store but not the only type
- **Structure:**
- Determined by research question
- stores impose structure so match structure to store
- **Interaction:**
- how you format/reformat your data
- based on what analysis you do
- one way or many ways
- **Management:**
- logistics around your data
- who collects it, and how frequently
- how many people access it?
- how long does it need to be available
- **Computing Resources:**
- size of your data
- software you have access to, features you need
:::
## Road Map{background-image="img/slides/trail.png" background-size="40%"
background-opacity="0.9" background-position="80% 30%"}
::: {style="font-size: 90%;"}
- Data
- What is data?
- Data Types
- Data Structures
- Data Stores
- Flat File vs. Database
- Spreadsheet Software
- Relational Databases
- NoSQL Databases
- Picking a Data Store
:::
### Credits {background-image="img/slides/trail.png"
background-size="8%" background-opacity="0.9"
background-position="97% 97%"}
::: {style="font-size: 70%;"}
All images were created by Elise Hellwig unless otherwise noted. Movie
information courtesy of IMDb ([https://www.imdb.com][imdb]). Used with
permission for non-commercial purposes only.
[imdb]: https://www.imdb.com
:::
#### Icons - color modified
::: {style="font-size: 45%;"}
Introduction: [By SkepticalScience - Own work][rm], CC BY-SA 4.0
Data: [By priyanka, "data", an icon from Noun Project][fr], CC BY 4.0
Tabular Data: [By Adam Mullin - Noun Project][tad], CC0
Tree Data: [By HitomiAkane, Tree icon-arzwiki.svg][td], CC BY-SA 4.0
Graph Data: [By Adam Beasley - The Noun Project][gd], CC BY 3.0
Relational Data: [categories by Nira Inds, Noun Project][rd], CC BY 3.0
Data Stores: [By Gaelen Pinnock][ds] - Designer commissioned by the UCT Research
office, CC BY-SA 4.0
Spreadsheets: [By Icons8 - Noun Project][ss], CC0
Relational Databases: [By Aybige - The Noun Project][rd], CC BY 4.0
NoSQL Databases: [By Five by Five - Noun Project][nd], CC0
How To Decide: [By SimpleIcon http://www.simpleicon.com/][htd], CC BY 3.0,
Further Reading: [By Icon Lauk from the Noun Project][fr], CC BY 3.0
:::
[rm]: https://commons.wikimedia.org/w/index.php?curid=99619583
[tad]: https://commons.wikimedia.org/w/index.php?curid=67122938
[td]: https://commons.wikimedia.org/w/index.php?curid=130967171
[gd]: https://commons.wikimedia.org/w/index.php?curid=105266675
[rd]: https://thenounproject.com/icon/categories-6069462/
[ds]: https://commons.wikimedia.org/w/index.php?curid=78355715
[ss]: https://commons.wikimedia.org/w/index.php?curid=67122942
[rd]: https://commons.wikimedia.org/w/index.php?curid=64472365
[nd]: https://commons.wikimedia.org/w/index.php?curid=64905590
[htd]: https://commons.wikimedia.org/w/index.php?curid=47382021
[fr]: https://commons.wikimedia.org/w/index.php?curid=109499378
# Data{background-image="img/slides/Noun_Data.png" background-size="95%"
background-opacity="0.1"}
<br>
> Data (noun): Quantities, characters, or symbols...considered collectively.
>
> \- Oxford English Dictionary
:::{.notes}
- Oxford focuses on digital data, but we know data is not just digital
:::
## What is data?{background-image="img/slides/Noun_Data.png"
background-size="8%" background-position="97% 97%"}
<br>
<center>
**Data is information translated into a form for storage and later use. **
</center>
::: columns
::: {.column width="60%"}
That form could be:
- Rows and columns of a spreadsheet
- A visual diagram
- Written human language
- And many others...
:::
::: {.column width="40%"}
![](img/cuniform.jpg){width="65%"}
:::
:::
:::{.notes}
- paper is still data, and can be a problem
- Clay cuniform tablet, Neo-Sumerian 2041 BCE, cattle receipt
- form is the data's structure
- what form our data takes can help guide our choice of data store
- spreadsheets are very familiar
- people now think of language as data
So how to we categorize our data?
:::
## Data Types{background-image="img/slides/Noun_Data.png"
background-size="8%" background-position="97% 97%"}
Data type tells your computer what types of operations make sense.
- integer
- decimal/floating point numbers
- categorical (small, medium, large)
- characters (text)
- Boolean values (TRUE or FALSE)
- dates and times
- spatial data
:::{.notes}
- Side effects of working on a computer
- May be different than computer science and informatics data types
- tells the computer what to do with a piece of information
- Single point can have data type
- 1 as int, decimal, text and date
:::
## Data Structures{background-image="img/slides/Noun_Data.png"
background-size="8%" background-position="97% 97%"}
<br>
<br>
::: {style="font-size: 130%;"}
Data Structure: a way of organizing data that makes it easier to store and use
:::
<br>
<br>
::: {style="font-size: 200%; text-align: center;"}
Question → Data structure
:::
<br>
:::{.notes}
- capture info about relationship between data pts
- Need multiple points for structure
- structure makes some Qs easier and others harder
- structure choice just as important as analysis choice
:::
## Data Structures{background-image="img/slides/Noun_Data.png"
background-size="8%" background-position="97% 97%"}
::: {style="font-size: 180%;"}
- Tabular/columnar ![](img/slides/tabular.png){width="7%"}
- Tree ![](img/slides/tree.svg){width="10%"}
- Graph ![](img/slides/network.png){width="10%"}
- Relational ![](img/slides/categories.png){width="10%"}
:::
:::{.notes}
- may see yours already but don't worry if not
- not an exhaustive list
- if you don't see yours feel free to ask about it
:::
## Tabular Data{background-image="img/slides/tabular.png"
background-size="6%" background-opacity="0.8"
background-position="39% 9%"}
::: {style="font-size: 60%;"}
```{r, echo=FALSE}
library(kableExtra)
mpg_cap = paste("A subset of the mtcars data set, containing information",
"about 32 cars from the 1974 Motor Trend Magazine",
"(Henderson and Velleman 1981).")
kbl(mpg, caption = mpg_cap) |>
scroll_box(width = "100%", height = "550px")
```
:::
:::{.notes}
- rows + columns is organizing principle, mention convention
- entities can be summarized with same set of chars
- focus on questions over entire set of obs
- sorting is easy, relationships not explicit
:::
### Tabular Data Research Questions{background-image="img/slides/tabular.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
::: {style="font-size: 130%;"}
- What is the average value of a particular measurement across a data set?
- What is the range or spread of values in a data set?
- Are there trends in the values of a variable?
- How to two columns in a data set relate to each other?
:::
:::{.notes}
- avg almond yield
- range normal values for vitamin A
- bay area temp increases
- test predict likelihood of complications from diabetes
:::
### `mtcars` Tabular Questions{background-image="img/slides/tabular.png"
background-size="6%"
background-opacity="0.8"
background-position="58% 9%"}
::: {style="font-size: 70%;"}
```{r}
kbl(mpg) |>
scroll_box(width = "100%", height = "600px")
```
:::
:::{.notes}
- avg, range of mpg
- relationship between mpg and other vars
- relationship between cylinders and hp
:::
## Tree Data{background-image="img/slides/tree.svg"
background-size="7%" background-opacity="0.8"
background-position="31% 7%"}
<br>
![](img/House_of_Tudor.png)
:::{.notes}
- organized around relationships (nested)
- relationships between entities is explicit
- structure can be more important than entities
:::
### Tree Structure{background-image="img/slides/tree.svg"
background-size="8%" background-opacity="0.8"
background-position="97% 97%"}
![](img/tree_data.png){width="130%" fig-align="center"}
:::{.notes}
- root is the center, distance defines place
- subsetting and searching is easy
- this is where text data lives (doc structure)
:::
### Tree Data Research Questions{background-image="img/slides/tree.svg"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
<br>
::: {style="font-size: 140%;"}
- How many nodes separate two entities?
- Which elements fall under a particular subtree?
- Text or directory searching
:::
:::{.notes}
- Elephants closer to rhinos or sloths
- how many dinosaurs are there
- which journals have most articles with AI this year
:::
### `mtcars` Tree Questions {background-image="img/slides/tree.svg"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
![](img/mpg_tree_data.png)
:::{.notes}
- needed to parse manufacturers from names
- how many models did japan produce
- which manufacturer did most models
:::
## Graph Data{background-image="img/slides/network.png"
background-size="6%" background-opacity="0.8"
background-position="36% 7%"}
![](img/slides/SocialNetworkAnalysis.png){width="120%" fig-align="center"}
:::{.notes}
- organized around relationships
- structure more important than obs
- no inherent center or hierarchy
:::
### Graph Data {background-image="img/slides/network.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
<br>
[](img/graph_data.png){width="75%" fig-align="center"}
:::{.notes}
- relationships can directional but don't have to be
- structure is contained in the data itself
- very flexible -> high computational intensity
:::
### Graph Data Research Questions {background-image="img/slides/network.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
::: {style="font-size: 130%;"}
- How many edges separate two entities?
- How many paths are there between two nodes?
- Which parts of the graph are most or least connected?
- What is the direction or volume of flow between entities?
:::
:::{.notes}
- number of connections from honolulu to cairo
- how many different ways to get from empire state building to brooklyn bridge
- hospital jobs with the highest exposure risk
- would a transit line to the north bay improve traffic
:::
### Abraham Lincoln Graph Data {background-image="img/slides/network.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
![](img/abraham_lincoln.png){fig-align="center"}
:::{.notes}
- mtcars is not graph structured, won't even try to reformat it
- as many links to things lincoln was opposed to as he supported
- wiki hyperlinks aren't the same as links in our head
- expect 4 clicks (lincoln movie, Daniel Day Lewis, wild river, kevin bacon)
- but do not directly link each movie in the database, only do notable work
:::
## Relational Data{background-image="img/slides/categories.png"
background-size="7%" background-opacity="0.8"
background-position="44% 6%"}
<br>
![](img/student_characteristics.png){width="140%" fig-align="center"}
<br>
:::{.notes}
- organized by group membership
- similarities
- trees: entities are nested within groups
- graphs: links between entities are non-hierarchical
- difference: entities can show up in multiple groups
- often used with other types of data (ex tabular)
:::
### Relational Data Research Questions {background-image="img/slides/categories.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
::: {style="font-size: 140%;"}
- Which groups are the largest or smallest?
- Do certain memberships tend to co-occur?
- How many groups does an entity tend to belong to?
:::
:::{.notes}
- which state has most gvt agencies related to health and medicine
- do students majoring in Env sci and mgmnt join outdoor rec groups?
- How many diff roles does the average student play on campus
:::
### `mtcars` Relational Questions {background-image="img/slides/categories.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
![](img/mpg_relate_data.png){width="100%" fig-align="center"}
:::{.notes}
- not really any questions this structure is useful to use to ask
- can't even represent all the data (no numbers)
- this is why choosing the correct structure is important
:::
# Data Stores {background-image="img/slides/data-store.png"
background-size="60%"
background-opacity="0.1"}
> A data store is repository for persistently storing and managing collections
> of data which include not just repositories like databases, but also simpler
> store types such as simple files, emails etc.
>
> Wikipedia
:::{.notes}
- Now we will dig deeper on data stores themselves.
- Note: I make a lot of generalizations about how different software works
- You could fine counter examples to each
- ex. google sheets and concurrent editing without conflicts
- What I'm just saying is rule of thumb
- Ask if you have questions
:::
## Data Store Definitions {background-image="img/slides/data-store.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
<br>
::: {style="font-size: 120%;"}
**Data store:** where your data is saved + how you interact with your data
<br>
**GUI:** Graphical User Interface, a software application that allows you to
interact with the computer via icons, buttons, and windows.
:::
:::{.notes}
- Data store storage+interaction
- these can be independent or together in one software package
- can be very simple or complex
- They also may impose a structure
- Gui - graphical user interface
- as opposed to command line interface
:::
## Database Definitions {background-image="img/slides/data-store.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
<br>
::: {style="font-size: 120%;"}
**Query:** database commands that create, read, update, delete (CRUD)
<br>
**Transaction:** the unit of work in a database, succeeds or fails as a
unit. Allows database to prevent conflicts.
:::
:::{.notes}
- Query - how you interact with a database, submit through the command line
interface
- Transaction - database unit of work
- tracking transactions allows database to prevent conflicts
- transaction succeeds or fails as a unit
- if an update affects multiple parts of a database, the update only
succeeds if every individual part of it is allowed.
:::
## Types of Data Stores {background-image="img/slides/data-store.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
![](img/data_stores.png){width="100%" fig-align="center"}
:::{.notes}
- flat file + gui
- storage separate from interaction
- stand alone files, not linked elsewhere
- ex spreadsheet software with csv or xlsx
- dbms
- storage and interaction together
- data linked in some way
- Secret third type is to use a programming language like R or python
- we will talk about spreadsheets, RDBMS, and NoSQL MS
:::
# Spreadsheet Software{background-image="img/slides/spreadsheet.png"
background-size="60%"
background-opacity="0.2"}
## Spreadsheet Software{background-image="img/slides/spreadsheet.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
::: {style="font-size: 90%;"}
1. **Structure:** tabular
2. **Interaction:** Graphical User Interface (GUI), reformatting is hard
3. **Management:**
- Managing multiple users is challenging
- Easy to introduce typos or erros when adding data
4. **Computing Resources:**
- Software is easy to use and widely available
- GUI limits data size
- Lots of data duplication
:::
:::{.notes}
- Tabular structure
- Stand alone (not generally linked to other files)
- Supports relatively low complexity in data
- Interact via GUI or programming language
- One person can edit at a time
- Data storage determined by GUI, is generally low
- Software is very widely available and UC Davis provides licenses
- Very easy to use
:::
<!--
- Imposes tabular data structure
- Widely available and easy to use via a Graphical User Interface (GUI)
- Generally limited to 1 million rows or 10 million cells if using a GUI
- Setting permissions is cumbersome
- Easy to introduce typos or errors
- May cause a lot of data duplication
-->
## Spreadsheet Data{background-image="img/slides/spreadsheet.png"
background-size="6%"
background-opacity="0.8"
background-position="48% 6%"}
::: {style="font-size: 55%;"}
```{r, echo=FALSE}
library(data.table)
library(kableExtra)
dh = fread('data/die_hard.csv', header=FALSE)
setnames(dh, names(dh),
c('title_id', 'person_id', 'title', 'premiered',
'runtime', 'genres', 'rating', 'votes', 'name', 'birth',
'death', 'role', 'characters'))
dh_cap = paste("Information from IMDB about the Die Hard movie franchise and",
"the people who acted in those films.")
dh = dh[,.(title_id, person_id, title, name, characters, premiered,
runtime, genres, rating, votes, birth, death, role)]
kbl(dh, caption=dh_cap) |>
scroll_box(width = "100%", height = "600px")
```
:::
:::{.notes}
- lots of duplication (260)
- if there is a typo it may be hard to find
- may need to correct typos multiple times, in various places
- then redistribute the data
:::
## Example Spreadsheet Software{background-image="img/slides/spreadsheet.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
- Microsoft Excel
- Google Sheets
- Numbers
- LibreOffice Calc\*
- OpenRefine\*
- Open Science Framework\*
\* Open Source
:::{.notes}
- Excel also has analysis tools (especially financial)
- Google sheets has capability for simultaneous editing and some vc
- Open refine provides some data cleaning
- open science framework has project management tools as well
:::
# Relational Database Management Systems (RDBMS) {background-image="img/slides/database.png"
background-size="60%"
background-opacity="0.2"}
:::{.notes}
- This is what people generally mean when they say database
- Both the data storage mechanism and interaction engine
- Related to relational data but this is a data store not structure
:::
## RDBMSs{background-image="img/slides/database.png"
background-size="8%"
background-opacity="0.9"
background-position="97% 97%"}
::: {style="font-size: 77%;"}
1. **Structure:** Tables connected by shared columns called keys
2. **Interaction:**
- SQL (Structured Query Language)
- Data manipulation is easy and reproducible
3. **Management**
- Built in data quality control and multi-user management
- Standardizes data updates
- Provides definitive version of your data
4. **Computing Resources**
- Few built-in size restrictions
- Requires some specialized setup
- thousands of transactions per day
:::
:::{.notes}
- tabular and relational
- instead of GUI, use SQL on command line, much easier than PL
- interacting is reproducible
- standardizes process for updating data
- automatically deals with conflicts via transactions
- multiple people can edit at a time
- built in version control and admin
- easy to set permissions
- larger storage capacity, reduced data duplication
- free options and options through UC Davis Licensing
:::
## Relational Keys{background-image="img/slides/database.png"
background-size="8%"
background-opacity="0.9"
background-position="97% 97%"}
Pair of columns with the same values
![](img/slides/linked_tables.png)
:::{.notes}
- databases store connected data
- tables connected by shared columns = keys
- keys implement relational part of relational database
- Primary key = column in table where key uniquely identifies observations
- Foreign key = primary key in another table, isn't necessarily unique
- Allows us to look up phone number without storing phone number with sales
:::
## IMDb Entity Relationship Diagram {background-image="img/slides/database.png"
background-size="8%"
background-opacity="0.9"
background-position="97% 97%"}
![](img/imdb_ERD.png)
:::{.notes}
- visual representation of entire rdb with links drawn between key pairs
- list columns in each table and data types
- 3 types of relationships
:::
## Why use an RDBMS? {background-image="img/slides/database.png"
background-size="8%"
background-opacity="0.9"
background-position="97% 97%"}
::: {style="font-size: 120%;"}
- Reduce data duplication
- Speed up and standardize accessing and updating the data
- Ease of reformatting data
- Ensure data integrity
- Manage multiple users
:::
:::{.notes}
- duplication = 260 -> 156 is 40% reduction in size
- SQL makes everything standardized and reproducible
- update database once and everyone runs new query and gets new data
- very fast = 60M observations, query took 0.5 seconds
- relational nature makes it easy to recombine and reformat data
- data type rules mean QC is easier
- only change typos once in source table
- set permissions and transactions take care of conflicts
:::
## Example RDBMS Software {background-image="img/slides/database.png"
background-size="8%"
background-opacity="0.9"
background-position="97% 97%"}
::: {style="font-size: 60%;"}
```{r, echo=FALSE}
sql = read.csv('data/sql_software.csv')
sql_cols = c("Software", "Support", "Cost", "License", "Spatial Data")
kbl(sql, col.names=sql_cols)
```
:::
# NoSQL Management Systems{background-image="img/slides/nosql.png"
background-size="60%"
background-opacity="0.3"}
:::{.notes}
- Not only sql
- If you like the features of a relational database but you don't have
tabular data
:::
## NoSQL Databases{background-image="img/slides/nosql.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
::: {style="font-size: 77%;"}
1. **Structure:** documents, trees, graphs, key-value pairs, wide column tables
2. **Interaction:**
- Via various query languages
- Data manipulation is easy and reproducible
3. **Management**
- Multi-user management
- Standardizes data updates
- Provides somewhat definitive version of your data
4. **Computing Resources**
- No built-in size restrictions
- Requires some specialized setup
- millions of transactions per day
:::
:::{.notes}
- many data structures, but not all software serves all structures
- like sql data manipulation is easy and standardized
- Also has ways of dealing with multiple users/conflicts
- not as strict as nosql databases, vis a vis transactions
- even faster than SQL, because data isn't all linked
:::
## Why Use NoSQL Databases?{background-image="img/slides/nosql.png"
background-size="8%"
background-opacity="0.8"
background-position="97% 97%"}
::: {style="font-size: 140%;"}
- Compatible with multiple data structures
- Data transactions are much faster than other data stores
- Adding storage capacity is easier than for other data stores
:::
:::{.notes}
- many data structures, but not all software serves all structures
- like sql data manipulation is easy and standardized
- Also has ways of dealing with
- not as strict as nosql databases, vis a vis transactions
- even faster than SQL, because data isn't all linked
:::