Skip to content

Commit 63ae691

Browse files
committed
improved normal forms
1 parent d1caff1 commit 63ae691

File tree

15 files changed

+220
-103
lines changed

15 files changed

+220
-103
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ The slides in German language can be found at <https://thomasweise.github.io/dat
8383
39. [Logisches Schema: Beziehungsattribute](https://thomasweise.github.io/databasesSlidesDE/39_logisches_schema_beziehungsattribute.pdf)
8484
40. [Logisches Schema: Beziehungen höheren Grades](https://thomasweise.github.io/databasesSlidesDE/40_logisches_schema_beziehungen_höheren_grades.pdf)
8585
41. [Logisches Schema: 1.&nbsp;Normalform](https://thomasweise.github.io/databasesSlidesDE/41_logisches_schema_1nf.pdf)
86+
42. [Logisches Schema: 2.&nbsp;Normalform](https://thomasweise.github.io/databasesSlidesDE/42_logisches_schema_2nf.pdf)
87+
43. [Logisches Schema: 3.&nbsp;Normalform](https://thomasweise.github.io/databasesSlidesDE/43_logisches_schema_3nf.pdf)
8688

8789

8890
### 2.4. The Examples

download.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cd "$downloadDir"
2828
mkdir slidesDE
2929
cd slidesDE
3030

31-
"$download" "databasesSlidesDE" "01_organisation.pdf" "02_einleitung.pdf" "03_anforderungen.pdf" "04_geschichte.pdf" "05_software_und_literatur.pdf" "06_postgresql_installieren.pdf" "07_beispiele_herunterladen.pdf" "08_fabrik_datenbank_benutzer_und_db.pdf" "09_fabrik_datenbank_tabelle_product.pdf" "10_fabrik_datenbank_tabelle_customer.pdf" "11_fabrik_datenbank_tabelle_demand.pdf" "12_fabrik_datenbank_joins_und_views.pdf" "13_fabrik_datenbank_daten_ändern_und_löschen.pdf" "15_psycopg_installieren.pdf" "16_fabrik_datenbank_von_python_auf_postgresql_zugreifen.pdf" "17_libreoffice_installieren.pdf" "18_fabrik_datenbank_libreoffice_base_verbinden.pdf" "19_fabrik_datenbank_libreoffice_base_tabellen_und_sichten.pdf" "20_fabrik_datenbank_libreoffice_base_erd.pdf" "21_fabrik_datenbank_libreoffice_base_formulare.pdf" "22_fabrik_datenbank_libreoffice_base_berichte.pdf" "23_fabrik_datenbank_aufräumen.pdf" "24_entwicklung.pdf" "25_anforderungen.pdf" "26_yed_installieren.pdf" "27_konzeptuelles_schema_entitäten_und_attribute.pdf" "28_konzeptuelles_schema_schlüssel.pdf" "29_konzeptuelles_schema_beziehungen.pdf" "30_konzeptuelles_schema_schwache_entitäten.pdf" "31_konzeptuelles_schema_beziehungskardinalität.pdf" "32_konzeptuelles_schema_kompakte_notation.pdf" "33_datenmodell_auswahl.pdf" "34_logisches_schema_relationales_datenmodell.pdf" "35_pgmodeler_installieren.pdf" "36_logisches_schema_entitäten_zu_tabellen.pdf" "37_logisches_schema_beziehungen.pdf" "38_logisches_schema_schwache_entitäten.pdf" "39_logisches_schema_beziehungsattribute.pdf" "40_logisches_schema_beziehungen_höheren_grades.pdf"
31+
"$download" "databasesSlidesDE" "01_organisation.pdf" "02_einleitung.pdf" "03_anforderungen.pdf" "04_geschichte.pdf" "05_software_und_literatur.pdf" "06_postgresql_installieren.pdf" "07_beispiele_herunterladen.pdf" "08_fabrik_datenbank_benutzer_und_db.pdf" "09_fabrik_datenbank_tabelle_product.pdf" "10_fabrik_datenbank_tabelle_customer.pdf" "11_fabrik_datenbank_tabelle_demand.pdf" "12_fabrik_datenbank_joins_und_views.pdf" "13_fabrik_datenbank_daten_ändern_und_löschen.pdf" "15_psycopg_installieren.pdf" "16_fabrik_datenbank_von_python_auf_postgresql_zugreifen.pdf" "17_libreoffice_installieren.pdf" "18_fabrik_datenbank_libreoffice_base_verbinden.pdf" "19_fabrik_datenbank_libreoffice_base_tabellen_und_sichten.pdf" "20_fabrik_datenbank_libreoffice_base_erd.pdf" "21_fabrik_datenbank_libreoffice_base_formulare.pdf" "22_fabrik_datenbank_libreoffice_base_berichte.pdf" "23_fabrik_datenbank_aufräumen.pdf" "24_entwicklung.pdf" "25_anforderungen.pdf" "26_yed_installieren.pdf" "27_konzeptuelles_schema_entitäten_und_attribute.pdf" "28_konzeptuelles_schema_schlüssel.pdf" "29_konzeptuelles_schema_beziehungen.pdf" "30_konzeptuelles_schema_schwache_entitäten.pdf" "31_konzeptuelles_schema_beziehungskardinalität.pdf" "32_konzeptuelles_schema_kompakte_notation.pdf" "33_datenmodell_auswahl.pdf" "34_logisches_schema_relationales_datenmodell.pdf" "35_pgmodeler_installieren.pdf" "36_logisches_schema_entitäten_zu_tabellen.pdf" "37_logisches_schema_beziehungen.pdf" "38_logisches_schema_schwache_entitäten.pdf" "39_logisches_schema_beziehungsattribute.pdf" "40_logisches_schema_beziehungen_höheren_grades.pdf" "41_logisches_schema_1nf.pdf" "42_logisches_schema_2nf.pdf" "43_logisches_schema_3nf.pdf"
3232

3333
"$download" "programmingWithPythonSlidesDE" "03_python_installieren.pdf"
3434
mv "03_python_installieren.pdf" "14_python_installieren_03_python_course.pdf"

text/main/designAndModeling/logicalSchema/normalization/1/1.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
\FloatBarrier%
2727
\hinput{composite}{composite}%
2828
\hinput{multivalued}{multivalued}%
29+
\hinput{summary}{summary}%
2930
\FloatBarrier%
3031
\endhsection%
3132
%

text/main/designAndModeling/logicalSchema/normalization/1/multivalued/multivalued.tex

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,7 @@
237237
This time, it is the other way around.
238238
If we had implemented all constraints of the original model, then our \sqlilIdx{INSERT} statements would have become more complicated.
239239
The queries later become much easier.
240-
Either way, our data is certainly \inQuotes{cleaner} and easier to handle in the \pgls{1NF}.
241-
242-
Normalizing data to obey the \pgls{1NF} means to implement the relational data model consistently at the logical level.
243-
Most often, we will naturally produce data that conforms with the \pgls{1NF} when we translate a conceptual model to a logical model.
244-
After all, we did learn exactly how to do that the right way.
245-
However, if our conceptual model does not fit to \pgls{1NF}, we may end up with convoluted structures of repeating groups or attriutes glued together into one that should actual be separate.
246-
This can indeed happen.
247-
We said so very often that the conceptual schema should be technology-agnostic.
248-
So we can hardly complain if such a model schema emerges that does not fit to our relational likings.
249-
Therefore, care must be taken during the logical model design.
250-
If we really need to create a logical model that deviates from the conceptual one to achieve proper normalization, we may wish to go back and also modify the conceptual model accordingly.
251-
Because we do not want to end up with design documents that contradict each other.%
240+
Either way, our data is certainly \inQuotes{cleaner} and easier to handle in the \pgls{1NF}.%
252241
\FloatBarrier%
253242
\endhsection%
254243
\endhsection%
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
\hsection{Summary}%
2+
Normalizing data to obey the \pgls{1NF} means to implement the relational data model consistently at the logical level.
3+
Most often, we will naturally produce data that conforms with the \pgls{1NF} when we translate a conceptual model to a logical model.
4+
After all, we did learn exactly how to do that the right way.
5+
However, if our conceptual model does not fit to \pgls{1NF}, we may end up with convoluted structures of repeating groups or attriutes glued together into one that should actual be separate.
6+
This can indeed happen.
7+
We said so very often that the conceptual schema should be technology-agnostic.
8+
So we can hardly complain if such a model schema emerges that does not fit to our relational likings.
9+
Therefore, care must be taken during the logical model design.
10+
If we really need to create a logical model that deviates from the conceptual one to achieve proper normalization, we may wish to go back and also modify the conceptual model accordingly.
11+
Because we do not want to end up with design documents that contradict each other.%
12+
\endhsection%

text/main/designAndModeling/logicalSchema/normalization/2/2.tex

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
\hsection{Second Normal Form}%
22
\label{sec:normalForm:2}%
33
%
4+
We already learned about the \pgls{1NF}.
5+
It will not suprise you that this is not the only normal form.
6+
47
The \glsFull{2NF} deals with the relationship between key attributes and non-key attributes~\cite{C1971FNOTDBRM,C1971NDBSABT,K1983ASGTFNFIRDT,D2003AITDS,EN2015FODS}.
58
It applies to composite keys only, i.e., keys that consist of multiple columns of a table.
69
Back in \cref{def:key,def:key2}, we learned that a key can be used to uniquely identify entities.
7-
If a key~$X$ uniquely identifies an object, then this means that all the other attributes of an entity provide information about that object and, hence, that key.
10+
If a key~$X$ uniquely identifies an entity, then this means that all the other attributes of the entity basically provide additional information about that key.
811
In a table in the relational model, a key is a unique identifier for each row.
912
In other words, there can be at most one row for each value of~$X$.
1013
All the other columns provide additional information about the real-world object represented by that key.
@@ -21,28 +24,33 @@
2124
This can be written as~$\funcDepb{X}{Y}$.%
2225
\end{definition}%
2326
%
24-
In other words, if $\funcDepb{X}{Y}$ and $X$~is a key, then it is invalid to have two records with the same value of~$X$ but different values of~$Y$~\cite{K1983ASGTFNFIRDT}.
25-
A given value of the key~$X$ must always occur with the same value of~$Y$.
27+
In other words, if $\funcDepb{X}{Y}$, then there are no two records with the same value of~$X$ but different values of~$Y$~\cite{K1983ASGTFNFIRDT}.
28+
A given value of the key~$X$ must always occur with the same associated value of~$Y$.
2629
Also, if $X$ is a key, then all other columns are by definition dependent on~$X$, simply because there cannot be two rows in a table with the same value of~$X$.
2730

2831
The relational schema of relation~$R$ be~\relSchemab{R} and a key be~$X\subseteq\relSchemab{R}$.
29-
Of course, all attributes~$a$ in\relSchemab{R} depend on the key attributes~$X$, i.e., it always holds that~$\funcDepb{X}{a}$.
32+
Of course, all attributes~$a$ in~\relSchemab{R} depend on the key attributes~$X$, i.e., it always holds that~$\funcDepb{X}{a}$.
3033
Let us approach a definition of the \pgls{2NF} using \pglspl{funcDep}.
3134
If the \pgls{2NF} is observed, then for all attributes~$a\in\relSchemab{R}$ that are not part of the key~$X$~(meaning $a \not\in X$), there does \emph{not} exist a proper subset~$X'\subset X$ such that~$a$ functionally depends on~$X'$, i.e.~$\funcDepb{X'}{a}$.
3235
(\emph{Proper} means that $X'\neq X$.)
3336
In the \pgls{2NF}, all attributes depend on the \emph{complete} key~$X$.
3437

3538
However, this definition is not fully correct.
3639
As we discussed before and will discuss again later, there can be multiple keys, i.e., multiple sets of attributes, that uniquely identify rows in~$R$.
40+
Yes, we do choose one as primary key, but there may be more keys.
41+
This is especially true if we choose a surrogate primary key because the other candidate keys are too large.
3742
The non-key attributes must depend on all of these keys in their entirety.
38-
It is not permitted that they depend any subset of any key.
43+
Under the \pgls{2NF}, it is not permitted that they depend any subset of any key.
3944
The correct definition for the \pgls{2NF} there is given as follows~\cite{SS2005EIDDDFDB:SDWSD2}:%
4045
%
4146
\begin{definition}[\glsreset{2NF}\Pgls{2NF}]%
4247
\label{def:2nf}%
4348
A relation~$R$ with the primary key~$P\subseteq\relSchema{R}$ is in the \glsreset{2NF}\pgls{2NF} if and only if it is in the \pgls{1NF} and for all sets of attributes~$X\subseteq\relSchemab{R}$ and all attributes~$a\in\relSchemab{R}$ with~$a\not\in X$, $a\not\in P$ and~$\funcDepb{X}{a}$, it holds that $X$ is either a key or a super key, but not a proper subset of any key of~$R$.%
4449
\end{definition}%
4550
%
51+
This definition may not be entirely clear at first glance.
52+
Let us do an example to understand it better.%
53+
%
4654
\hinput{rooms}{rooms.tex}%
4755
\hinput{summary}{summary.tex}%
4856
%

0 commit comments

Comments
 (0)