|
1 | 1 | \hsection{Second Normal Form}% |
2 | 2 | \label{sec:normalForm:2}% |
3 | 3 | % |
| 4 | +We already learned about the \pgls{1NF}. |
| 5 | +It will not suprise you that this is not the only normal form. |
| 6 | + |
4 | 7 | The \glsFull{2NF} deals with the relationship between key attributes and non-key attributes~\cite{C1971FNOTDBRM,C1971NDBSABT,K1983ASGTFNFIRDT,D2003AITDS,EN2015FODS}. |
5 | 8 | It applies to composite keys only, i.e., keys that consist of multiple columns of a table. |
6 | 9 | 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. |
8 | 11 | In a table in the relational model, a key is a unique identifier for each row. |
9 | 12 | In other words, there can be at most one row for each value of~$X$. |
10 | 13 | All the other columns provide additional information about the real-world object represented by that key. |
|
21 | 24 | This can be written as~$\funcDepb{X}{Y}$.% |
22 | 25 | \end{definition}% |
23 | 26 | % |
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$. |
26 | 29 | 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$. |
27 | 30 |
|
28 | 31 | 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}$. |
30 | 33 | Let us approach a definition of the \pgls{2NF} using \pglspl{funcDep}. |
31 | 34 | 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}$. |
32 | 35 | (\emph{Proper} means that $X'\neq X$.) |
33 | 36 | In the \pgls{2NF}, all attributes depend on the \emph{complete} key~$X$. |
34 | 37 |
|
35 | 38 | However, this definition is not fully correct. |
36 | 39 | 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. |
37 | 42 | 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. |
39 | 44 | The correct definition for the \pgls{2NF} there is given as follows~\cite{SS2005EIDDDFDB:SDWSD2}:% |
40 | 45 | % |
41 | 46 | \begin{definition}[\glsreset{2NF}\Pgls{2NF}]% |
42 | 47 | \label{def:2nf}% |
43 | 48 | 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$.% |
44 | 49 | \end{definition}% |
45 | 50 | % |
| 51 | +This definition may not be entirely clear at first glance. |
| 52 | +Let us do an example to understand it better.% |
| 53 | +% |
46 | 54 | \hinput{rooms}{rooms.tex}% |
47 | 55 | \hinput{summary}{summary.tex}% |
48 | 56 | % |
|
0 commit comments