diff --git a/semester4/dmdb/data-modelling-databases-summary.pdf b/semester4/dmdb/data-modelling-databases-summary.pdf index 1e6ce05..376e786 100644 Binary files a/semester4/dmdb/data-modelling-databases-summary.pdf and b/semester4/dmdb/data-modelling-databases-summary.pdf differ diff --git a/semester4/dmdb/parts/00_relational-model_logic/00_model/01_keys.tex b/semester4/dmdb/parts/00_relational-model_logic/00_model/01_keys.tex index 9856581..42c8c54 100644 --- a/semester4/dmdb/parts/00_relational-model_logic/00_model/01_keys.tex +++ b/semester4/dmdb/parts/00_relational-model_logic/00_model/01_keys.tex @@ -1,12 +1,12 @@ \subsubsection{Keys} \label{sec:relations-keys} -\inlinedefinition[Candidate Key] The minimal set of fields that identify each tuple uniquely +\inlinedefinition[Candidate Key] The minimal set of fields that identify each tuple uniquely (non-duplicate attributes (fields) typically) \inlinedefinition[Primary Key] A single candidate key, i.e. just a single field. We mark the primary key using \underline{underlining} in visual \glspl{schema}. Formally, we write $R(\underline{k : D_k}, a:D_a, b:D_b)$ for a given relation, with all valid instances fulfilling \[ - I \subseteq D_k \times D_a \times D_b \land \forall (k, a, b), (k', a', b') \in I : k = k' \rightarrow (a, b) = (a', b') + I \subseteq D_k \times D_a \times D_b \land \forall (k, a, b), (k', a', b') \in I : k = k' \rightarrow (a, b) = (a', b') \] i.e. if the key is equal, so is the rest of the tuple (thus they are one and the same\footnote{\hlhref{https://www.youtube.com/watch?v=tGeSEbYzhBU}{Heidrun is her name}}). diff --git a/semester4/dmdb/parts/02_theory-background/00_functional-dependencies/04_closure.tex b/semester4/dmdb/parts/02_theory-background/00_functional-dependencies/04_closure.tex index c616bac..9657c6f 100644 --- a/semester4/dmdb/parts/02_theory-background/00_functional-dependencies/04_closure.tex +++ b/semester4/dmdb/parts/02_theory-background/00_functional-dependencies/04_closure.tex @@ -1,3 +1,4 @@ +\newpage \subsubsection{Closure Algorithm} For the definition of the closure, see above. diff --git a/semester4/dmdb/parts/02_theory-background/00_functional-dependencies/06_intuition.tex b/semester4/dmdb/parts/02_theory-background/00_functional-dependencies/06_intuition.tex new file mode 100644 index 0000000..81f279a --- /dev/null +++ b/semester4/dmdb/parts/02_theory-background/00_functional-dependencies/06_intuition.tex @@ -0,0 +1,13 @@ +\subsubsection{Intuition} +Adapted from the \hlhref{https://en.wikipedia.org/wiki/Functional_dependency}{Wikipedia Article on this topic} + +The idea of functional dependencies is to describe which attributes belong to the \textit{determinant set} $X$ and which belong to the \textit{dependent set} $Y$. +The values of the attributes in the \textit{determinant set} determine the values of $Y$. + +Thus, for a relation $R$, with $X, Y \subseteq R$, with $X \rightarrow Y$: +\begin{itemize} + \item When attributes $X$ have known values (let's call them $\bm{x}$), + then the values of for their corresponding $Y$ attributes can be determined by looking them up in \bi{any} tuple of $R$ containing the values $\bm{x}$ + \item Two tuples sharing the same values of $X$ share the same values of $Y$. +\end{itemize} +A FD $X \rightarrow Y$ is \textit{trivial}, if $Y \subseteq X$ diff --git a/semester4/dmdb/parts/02_theory-background/01_normal-forms/02_second-nf.tex b/semester4/dmdb/parts/02_theory-background/01_normal-forms/02_second-nf.tex index 0e20af8..ccb0e8b 100644 --- a/semester4/dmdb/parts/02_theory-background/01_normal-forms/02_second-nf.tex +++ b/semester4/dmdb/parts/02_theory-background/01_normal-forms/02_second-nf.tex @@ -1,4 +1,4 @@ -\subsection{Second Normal Form} +\subsubsection{Second Normal Form} % The two dependencies $\{ \text{Legi}, \text{Nr} \} \rightrightarrow \{ \text{Name}, \text{Semester} \}$, % $\{ \text{Legi} \} \rightrightarrow \{ \text{Name}, \text{Semester} \}$ state the following: % diff --git a/semester4/dmdb/parts/02_theory-background/01_normal-forms/07_overview.tex b/semester4/dmdb/parts/02_theory-background/01_normal-forms/07_overview.tex new file mode 100644 index 0000000..a9ce4f7 --- /dev/null +++ b/semester4/dmdb/parts/02_theory-background/01_normal-forms/07_overview.tex @@ -0,0 +1,18 @@ +\subsubsection{Overview} +This overview is adapted from \hlhref{https://en.wikipedia.org/wiki/Database_normalization\#Normal_forms}{this Wikipedia article}. +All constraint definitions in {\scriptsize smaller font} are informal. Note that \textit{prime attributes} are the attributes that make up a candidate key, +also known as \textit{key attributes} + +\newcommand{\cross}{\ding{55}} +\begin{tables}{p{10cm}lllll}{Constraint & UNF & 1NF & 2NF & 3NF & BCNF} + Unique rows {\scriptsize (no duplicates)} + & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\ + Scalar Columns {\scriptsize (Columns can't contain relations or composite values)} + & \cross & \checkmark & \checkmark & \checkmark & \checkmark \\ + Every non-prime attribute has a full FD on each candidate key {\scriptsize (Attributes depend on the whole of every key)} + & \cross & \cross & \checkmark & \checkmark & \checkmark \\ + Every Non-trivial FD begins either with superkey or ends with prime attribute {\scriptsize (Attributes depend only on candidate keys)} + & \cross & \cross & \cross & \checkmark & \checkmark \\ + Every non-trivial FD begins with a superkey + & \cross & \cross & \cross & \checkmark & \checkmark \\ +\end{tables} diff --git a/semester4/dmdb/parts/02_theory-background/main.tex b/semester4/dmdb/parts/02_theory-background/main.tex index a92ffcd..a42b11f 100644 --- a/semester4/dmdb/parts/02_theory-background/main.tex +++ b/semester4/dmdb/parts/02_theory-background/main.tex @@ -7,6 +7,7 @@ \input{parts/02_theory-background/00_functional-dependencies/03_other-rules.tex} \input{parts/02_theory-background/00_functional-dependencies/04_closure.tex} \input{parts/02_theory-background/00_functional-dependencies/05_using.tex} +\input{parts/02_theory-background/00_functional-dependencies/06_intuition.tex} % \input{parts/02_theory-background/00_functional-dependencies/} \input{parts/02_theory-background/01_normal-forms/00_intro.tex} @@ -16,6 +17,7 @@ \input{parts/02_theory-background/01_normal-forms/04_bncf.tex} \input{parts/02_theory-background/01_normal-forms/05_decomposition-algorithm.tex} \input{parts/02_theory-background/01_normal-forms/06_synthesis-algorightm.tex} +\input{parts/02_theory-background/01_normal-forms/07_overview.tex} % \input{parts/02_theory-background/01_normal-forms/} % \input{parts/02_theory-background/}