5. Otras simulaciones
5.2 Caja con el techo deslizante con saltos discretos
� 0
The results for strong update anomalies and NLNF are the same as for update anomalies and BCNF in the RDM. In summary, the results obtained for NLNF generalise all results from Theorem 1 .4 for BCNF in the RDM.
3.4 Decomposition into NLNF
So far we have presented the Nested List Normal Form as a goal that is desirable to achieve in the database design process. We now tackle the problem how to actually obtain NLNF. This is an important problem since, in general, it cannot be expected that the first design of a large and complex database schema is already optimised. Having achieved an agreement on a suitable database schema that meets the requirements of all parties involved in the lengthy design process, one wants to avoid starting all over again just to satisfy design criteria. It is much more desirable to provide automatic tools that transform a first design into an equivalent database schema which is in normal form. Of couse, it cannot be expected at all that such tools exist.
There are two competing approaches to relational database design: the
decomposition
approach [70] and thesynthesis
approach [4 1 , 49] . For a discussion and comparison of these two approaches see [102, 181] . In this section, we will focus on applying the decomposition approach to NLNF.3.4. 1 FDs and Decompositions
The first desirable property of a decomposition in relational databases is that it be a lossless join decomposition with respect to the given set of FDs. Informally, a decomposition
{R1 , . . . , Rn}
of a relation schemaR
is called lossless with respect to a given set E of FDson
R
if every relation that satisfies all FDs in E is the natural join of its projections onthe subschemata
Ri,
i.e.,r
= 7rR1 (r) l><l • • • l><lnRJr).
This implies that one can projecta relation onto the subschemata and then j oin the projections without losing or adding any information. In order to generalise this desirable property, we define the generalised natural join within our framework.
Definition 3.45. Let
N E
NA andX, Y E Sub(N) .
Let r1 <;:dom(X)
andr2
<;:dom (Y) .
Then
r1
l><lr2
={ t
Edam( X
UY) I :3t1
Er1 , t2
Er2.1r�uY (t)
=t1
andn9uY (t)
=t2}
is called thegeneralised natural join r1
l><lr2 of r1
andr2.
DWe will now show that any instance
r
<;:dom (N)
that satisfies an FDX
-+Y
onN
can be decomposed into its projections on
X
UY
andX U
ye without loss of information.The
projection 1r x ( r)
ofr
<;:dam ( N)
onX
ESub( N)
is defined as{ 1r� ( t) I t
Er}.
Theorem 3.46.
Let N
E NA, r
<;:dom (N) and X -+ Y an FD on N. If Fr X -+ Y,
then r
=nxuy (r)
l><lnxuyc (r) .
Proof.
One can see thatr
<;:nxuy (r)
l><lnxuyc (r)
is always satisfied. Lett
Enxuy (r)
l><lnxuyc (r)
andFr X -+ Y.
We show thatt E r.
There aret�
Enxuy(r)
andt;
Enxuyc (r)
witht�
=n�uy(t)
andt;
=nfuyc (t).
That means there aret1 , t2
Er
witht�
=7r�uy(tl)
andt;
=nfuyc (t2),
i.e.,7r�uy(t)
=7r�uy(ti)
andnfuyc (t)
=nfuyc (t2).
In particular,1r�(ti)
=1r�(t2)
and ast1, t2 E r
withFr X -+ Y
holds, we conclude1r
:(t1 )
=nP'(t2)
as well. Therefore,n�uy(ti)
=7f�uy(t2)
by Lemma 3.9 and therefore alson�uy (t)
=7r�uy(t2)·
Since alsonfuyc (t)
=nfuyc (t2)
holds we concludet
=t2
by Lemma 3.9. This means,t
E r. D3.4. DECOMPOSITION INTO NLNF Sebastian Link Theorem 3.46 suggests that the decomposition approach may be successfully applied to the class of FDs in the context of lists. It is important to note that the converse of Theorem 3.46 is wrong. Consider N
= L(A, B, C)
withr = { (a, b, c) , (a, b', c) }
and differentb, b'
Edom(B) .
Obviously,�r L(A) --+ L(B) ,
but 1f£(A,B)(
r) = { (a, b, ok) , (a, b', ok) }
and1fL(A,c)
(
r) = { (a, ok, c) } ,
i.e.,r =
1f£(A,B)(
r)
txJ 1f£(A,c)(
r)
. 3.4.2 The Decomposition AlgorithmGiven some nested attribute N and a set E of FDs defined on N, the decomposition approach aims at finding a set of subattributes of N each of which is in NLNF with respect to the corresponding set of all implied FDs on that subattribute. Moreover, any instance of
N
that satisfies all the FDs in E is the generalised natural join of its projections on all the subattributes, i.e. , every valid database on N can be decomposed without loss of information.Definition 3.47. Let N E N A,
N1 ,
. . . , Nk ESub(N) ,
and E a set of FDs defined on N. The set{ N1 ,
... , Nk}
is called aloss less join decomposition of N with respect to
E if andonly if N
= U{N1 ,
... , Nk}
andr =
7rN1(r)
txJ ·•· txJ 7rNk(
r)
holds for allr
�dom (N)
with Fr E. The set
{N1 ,
. . . , Nk}
is called alossless NLNF decomposition of
Nwith
respect to
E if and only if{ N1 ,
. . . , Nk}
is a lossless join decomposition of N with respect to E and Ni is in NLNF with respect to 1fN; (E+) for everyi =
1 ,. . . , k,
and where1rM (E)
= {X --+
y E EI X
u y :SM}.
DThe lossless join property guarantees that the information of any legal instance over the original nested attribute can be obtained by joining the information on all decomposed subattributes. An NLNF decomposition guarantees moreover that every decomposed sub attribute is in NLNF with respect to the projected sets of dependencies.
We will now show that it is possible to obtain a lossless NLNF decomposition for any given nested attribute N and any given set of FDs on N. Whenever an FD in the current state of the output schema violates NLNF, the decomposition algorithm removes the cause for this violation of NLNF by replacing the offending parent subattribute by two of its proper child subattributes which can be joined losslessly to reconstruct their parent.
Algorithm 3.4. 1
(
Lossless NLNF decomposition)
Input: N E N A, set E of FDs on NOutput: set S = { ( N1 , E1) , •••, (Nk, Ek) } where Ei is set of FDs on Ni E Sub(N)
and {N1, •• •, Nk} is lossless NLNF decomposition of N with respect to E
Method:
VAR
X,
Y ESub(N)
( 1 ) BEGIN
(2) IF N in NLNF with respect to E, THEN S : = { (N, E) } ;
(3) ELSE
(4) LET
X �
Y E E be not inevitable on N with respect to E and E� X �
N; (5) N1:= X
u Y ; (6) S:=
DECOMPOSE(N1 ,7rN1 (E+)) ;
(7) N2:= X
u ye ; (8) S:=
S U DECOMPOSE(N2 ,7rN2 (E+) ) ;
(9) ENDIF; (10) RETURN(S) ; ( 1 1 ) END ;Theorem 3.48.
Algorithm
3. 4 . 1is correct.
0
Proof.
The algorithm terminates with an NLNF decomposition. In each decomposition step N1 U N2=
N, i.e. , N = U { N1 , . . . , Nk } upon termination of the algorithm. Moreover, the algorithm continues the decomposition process whenever Ni is not in NLNF with respect to1fNi (L'+ ) .
Therefore, { N1 , . . . , Nk} is an NLNF decomposition.It remains to show that
r = 1fN1 (r)
[X] · · · [X]1fNk (r)
holds for anyr
� dom(N) withFr
E as well. Therefore, we consider the case whereX �
Y is some FD onM
which is not inevitable onM
with respect to7rM(E+)
and whereX
is not a superkey forM
with respect to7rM(E+) .
SinceF1rM(r) X �
Y, it follows that7rM (r) = 7rxuy (7rM (r))
[X]1fxuyc (7rM (r))
by Theorem 3.46. This, however, is equivalent t o
7rM (r)
=Jrxuy (r)
[X]7rxuyc (r) .
This showsthat the NLNF decomposition { N1 , . . . , Nk} is indeed lossless. D
One may replace line (5) of Algorithm 3.4 . 1 by N1
:= X U
yee . This would eliminate those non-maximal basis attributes of N in Y which do not have a superattribute in Ythat is also a maximal basis attribute of N. Such non-maximal basis attributes are also subattributes of ye , anyway. Since
X
� Y is not inevitable, at least one maximal basisattribute of N is a subattribute of Y by Lemma 3.30, i.e . , yee =!= >.. The resulting algorithm is still correct as yee U ye = N and
Fr X �
Y impliesFr X �
yee by the subattribute rule as yee :S Y . We illustrate Algorithm 3.4.1 with the following abstract example. We say that a set E of FDs iscovered
by another set fJ of FDs, if every FD inE
is implied by e.ExAMPLE 3 . 2 2 . Suppose N