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
|
---
author: Florian Fischer
theme: metropolis
aspectratio: 169
header-includes: |
\usepackage{adjustbox}
\let\tightlist\relax
---
## Wiederholung - n:m Beziehungen
##
Ein Versandhandel verwaltet Bestellungen in einer Tabelle mit folgendem Schema:
```{\small
\texttt{BESTELLUNG[\underline{KdNr}; Name; Vorame; Adresse; Telefon; \underline{ArtNr}; Artikel; Preis; Anzahl; \underline{BDatum}]}
}```{=latex}
\adjustbox{width=\textwidth}{
\begin{tabularx}{1.1\textwidth}{|l X X p{1.7cm} X c l l c X|}
\hline
\rowcolor{blue!20!white}\underline{KdNr} & Name & Vorname & Adresse & Telefon & \underline{ArtNr} & Artikel & Preis & Anz. & \underline{BDatum} \\
\hline
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\hline
123 & Mueller & Max & Postweg 8 & 555180 & 3434 & Hemd & 22,90 & 1 & 12.07.20 \\
\hline
123 & Mueller & Max & Postweg 8 & 555180 & 2827 & Jeans & 69,95 & 1 & 12.07.20 \\
\hline
123 & Mueller & Max & Postweg 8 & 555180 & 6001 & Rasierer & 49,00 & 1 & 12.07.20 \\
\hline
224 & Nowak & Beate & Goldstr. 7 & 555788 & 3434 & Hemd & 22,90 & 2 & 13.07.20 \\
\hline
224 & Nowak & Beate & Goldstr. 7 & 555788 & 1007 & Bluse & 43,50 & 2 & 13.07.20 \\
\hline
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\hline
\end{tabularx}
}
\pause
### \faIcon{desktop} Arbeitsauftrag - 3 min
* Überlege Dir welche Informationen werden unnötig oft gespeichert?
* Finde Probleme die durch das Tabellenschema entstehen wenn Datensätze geändert werden müssen.
## \faIcon{pencil-alt}
\large
Unter \beamerpgap{2}{\boldred{Redundanz}} versteht man die Mehrfachspeicherung von Daten.
Beim Ändern, Löschen oder Einfügen von Datensätzen können dadurch Probleme entstehen, sogenannte \beamerpgap{3}{\boldred{Anomalien}}.
##
\begin{tcolorbox}[colframe=orange, title=\faIcon{pencil-alt} UPDATE-Anomalie]
Änderungen an Daten können zu Inkonsistenzen führen.
\end{tcolorbox}
\adjustbox{width=\textwidth}{
\begin{tabularx}{1.1\textwidth}{|l X X p{1.7cm} X c l l c X|}
\hline
\rowcolor{blue!20!white}\underline{KdNr} & Name & Vorname & Adresse & Telefon & \underline{ArtNr} & Artikel & Preis & Anz. & \underline{BDatum} \\
\hline
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\hline
123 & Mueller & Max & Postweg 8 & \textcolor{red}{555161} & 3434 & Hemd & 22,90 & 1 & 12.07.20 \\
\hline
123 & Mueller & Max & Postweg 8 & \textcolor{magenta}{555180} & 2827 & Jeans & 69,95 & 1 & 12.07.20 \\
\hline
123 & Mueller & Max & Postweg 8 & \textcolor{magenta}{555180} & 6001 & Rasierer & 49,00 & 1 & 12.07.20 \\
\hline
224 & Nowak & Beate & Goldstr. 7 & 555788 & 3434 & Hemd & 22,90 & 2 & 13.07.20 \\
\hline
224 & Nowak & Beate & Goldstr. 7 & 555788 & 1007 & Bluse & 43,50 & 2 & 13.07.20 \\
\hline
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\hline
\end{tabularx}
}
##
\begin{tcolorbox}[colframe=orange, title=\faIcon{pencil-alt} DELETE-Anomalie]
Beim Löschen können ungewollte andere Informationen verloren gehen.
\end{tcolorbox}
Welche Informationen gehen verloren wenn abgeschlossene Bestellungen gelöscht werden?
### Verlorene Information
\pause
* Kundendaten (Name, Vorname, Adresse, Telefon)
* Produktinformationen (Artikel, Preis)
##
\begin{tcolorbox}[colframe=orange, title=\faIcon{pencil-alt} INSERT-Anomalie]
Neue Daten lassen sich nur einfügen, wenn \textbf{alle} Teile des Primärschlüssels bekannt sind.
\end{tcolorbox}
\adjustbox{width=\textwidth}{
\begin{tabularx}{1.1\textwidth}{|l X X p{1.7cm} X c l l c X|}
\hline
\rowcolor{blue!20!white}\underline{KdNr} & Name & Vorname & Adresse & Telefon & \underline{ArtNr} & Artikel & Preis & Anz. & \underline{BDatum} \\
\hline
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\hline
123 & Mueller & Max & Postweg 8 & 555180 & 3434 & Hemd & 22,90 & 1 & 12.07.20 \\
\hline
123 & Mueller & Max & Postweg 8 & 555180 & 2827 & Jeans & 69,95 & 1 & 12.07.20 \\
\hline
123 & Mueller & Max & Postweg 8 & 555180 & 6001 & Rasierer & 49,00 & 1 & 12.07.20 \\
\hline
224 & Nowak & Beate & Goldstr. 7 & 555788 & 3434 & Hemd & 22,90 & 2 & 13.07.20 \\
\hline
224 & Nowak & Beate & Goldstr. 7 & 555788 & 1007 & Bluse & 43,50 & 2 & 13.07.20 \\
\hline
\textcolor{red}{???} & \textcolor{red}{???} & \textcolor{red}{???} & \textcolor{red}{???} & \textcolor{red}{???} & \textcolor{red}{1974} & \textcolor{red}{Schuhe} & \textcolor{red}{99,95} & \textcolor{red}{???} & \textcolor{red}{???} \\
\hline
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\hline
\end{tabularx}
}
<!--  -->
\pause
Ein neues Produkt kann erst aufgenommen werden, wenn es auch bereits bestellt wurde.
## \faIcon{pencil-alt} Arbeitsauftrag: Modellierung \hfill 7 min
\large
Erstelle ein Klassendiagramm das die Klassen der Bestelltabelle und ihre Beziehungen darstellt.
Benenne die Beziehungen und gib ihre Kardinalitäten an.
\textit{(Du musst keine Attributen der Klassen angeben.)}
## Lösung
\centering
\scalebox{1.3}{
\begin{tikzpicture}
\node[draw] (k) {Kunde};
\node[draw,right=3cm of k] (b) {Bestellung};
\node[draw,right=3cm of b] (a) {Artikel};
\draw (k) -- (b) node[midway, above] {tätigt >};
\path (k) -- (b) node[very near start, above] {1};
\path (k) -- (b) node[very near end, above] {n};
\draw (b) -- (a) node[midway, above] {enthält >};
\path (b) -- (a) node[very near start, above] {m};
\path (b) -- (a) node[very near end, above] {n};
\end{tikzpicture}
}
## \faIcon{pencil-alt} Arbeitsauftrag: Tabellenschema \hfill 7 min
\large
Erstelle ein Tabellenschema, das dein Klassendiagramm in eine Datenbank überträgt.
Markiere Primär-/ und Fremschlüssels wie gewohnt.
\textit{(Du musst keine Datentypen der Attribute angeben.)}
## Lösung
\texttt{Kunde[\underline{KndNr}; Name; Vorname; Adresse; Telefon]}
\texttt{Bestellung[\underline{BDatum; \dashuline{KndNr}}]}
\texttt{Artikel[\underline{ArtNr}; Artikel; Preis]}
\texttt{Enthaelt[\underline{\dashuline{BDatum; KndNr}; \dashuline{ArtNr}}; Anzahl]};
|