Relational model database of mad science decomposition algorithm


Here Insert Picture Description

Decomposition of relational schema

A relational schema R <U, F> into several relational schema R1 <U1, F1>, R2 <U2, F2>, ..., Rn <Un, Fn> (where U = U1∪U2∪ ... ∪Un, and there Ui⊈Uj, Ri is F projected on the Ui), means that the corresponding data is stored in a two-dimensional table t dispersed into a plurality of two-dimensional tables t1, t2, ..., tn go (where ti t is the projection on the attribute set Ui). Claimed thatρ = {R1, R2, ..., Rk} is an exploded relational schema R

Relations normalization process model is through the decomposition pattern of relationships to achieve , but the low-level relational schema into several high-level relational schema approach is not unique. In these decomposition method, only to ensure that the decomposed relational schema and relational schema is equivalent to the original method makes sense.

关系模式分解等价性的三个判定准则:
 (1)分解具有“无损连接性”。
 (2)分解要“保持函数依赖”。 
 (3)分解既要“保持函数依赖”,又要具有“无损连接性”。 
 

Lossless join decomposition

If a relational model is decomposed into the relationship between two modes is relatively easy to decompose determines whether lossless connectivity. However, if the relationship between a model divided into three or more relational model, to be determined whether the destructive decomposition connectivity requires a relatively sophisticated algorithm.
The case will be divided into two modes, the following special CRITERIA may be employed.

Two decomposition theorem:
relational schema R (U, F) is an exploded ρ = {R1 (U1, F1 ), R2 (U2, F2)}
having a lossless connectivity necessary and sufficient conditions areU1∩U2→U1-U2∈F+ 或 U1∩U2→U2-U1∈F+
examples:

将给定的关系模式 R(U,F),U= {A,B,C,D},F={A→B,B→C,A→D}, 有如下两个分解: ρ1={ ABC,ACD} ρ2={ ABD,BC} 并检验这两个分解的无损连接性
. 解:可根据无损连接充分必要条件判断本题:
 (1)因为 ABC∩ACD =C
  ABC-ACD=B
   ACD-ABC=D 所以 C→B不属于F+ ,C→D不属于F+ 故ρ1为有损连接. 
   (2)因为 ABD∩ABC=A   
   ABD-ABC=D 
   ABC-ABD=C 所以 A→D∈F+ 故ρ2为无损连接. 注意:尽管 A→C不属于F+,但根据无损连接充分必要条件只要满足一个即可,故ρ2为无损 连接.
   

Checking algorithm:
Input: relational schema R (A1, A2, ..., An), functional dependency cluster F, decomposition ρ = {R1, R2, ... , Rk}.
Output: [rho] determining whether the lossless connectivity.
Method
(1)构造一个 k 行 n 列的表,第 i 行对应于关系模式 Ri,第 j 列对应于属性 Aj.如果 Aj∈Ri, 则在第 i 行第 j 列上放符号 aj,否则放符号 bij. (2)重复考察 F 中的每一个函数依赖,并修改表中的元素.其方法如下:取 F 中一个函 数依赖 X→Y,在 X 的分量中寻找相同的行,然后将这些行中 Y 的分量改为相同的符号, 如果其中有 aj,则将 bij改为 aj;若其中无 aj,则全部改为 bij(i 是这些行的行号最小值). (3)如果发现表中某一行变成了 a1,a2,…,an,则分解ρ具有无损连接性;如果 F 中所 有函数依赖都不能再修改表中的内容,且没有发现这样的行,则分解ρ不具有无损连接性.

example

Provided relational schema R (G, H, L, M, O), F = {GL → O, O → M, G → H, H → M}, determines the decomposition ρ = {R1 (GHL), R2 (MO) , R3 (GLO)} if lossless connection.
Two-dimensional table as follows:
Here Insert Picture Description

Table modified as follows:
Here Insert Picture Description

Modified table can be seen that the first row appears a1, a2, a3, a4, a5, so that non-destructive decomposition connectivity.

Here Insert Picture Description

Holding the split function dependent

Holding means decomposition functional dependency in the decomposition process function dependent mode characteristics can not be lost, and can not destroy the original mode decomposition semantics.
Seen from the definition, the function dependence maintaining means is an exploded:When R a relational schema decomposition, without loss of semantics, and after decomposition of the original pattern function R dependence, are dispersed in the sub-mode decomposition

Decision process:

R & lt set (U, F) is a relational schema, where U is the set of attributes of its whole, F is a function of its dependency set, Z contained in U, put all of the function dependence F + Z is referred to as a set of F projected in the Z, denoted Πz (F), i.e.
Πz (F) = {X → Y | (X → Y∈F +) and (XY contained in Z)}
is provided to a relational schema R exploded ⍴ = {R1 , R2, ..., Rk}, F is a function dependent set R, if F is equivalent to the relationship between the decomposition and each set having a functional dependency called decomposition retention ρ

example:

Provided relational schema R = {CITY, STREET, POSTALCODE ) represents the zip code of each city streets, where the property represent city, street name, and postal code, F = {(CITY, STREET ) → POSTALCODE, POSTALCODE → CITY)}. If R is decomposed into ⍴ = {R1, R2}, where R1 = {STREET, POSTALCODE}, R2 = {CITY, POSTALCODE}. This decomposition is determined whether the connection remains intact and functional dependence.
Solution: The necessary and sufficient conditions for the lossless connection, since R1∩R2=POSTALCODE, R2-R1=CITY, POSTALCODE→CITYit is connected to this decomposition is lossless.
The functional dependency definitions and F1 = ΠR1 (F) = empty set, F2 of ΠR2  = (F.)} = {POSTALCODE → the CITY
F1∪F2 the CITY} = {POSTALCODE → ≠ F. Therefore, this decomposition does not remain functional dependence

Case summary

Analyze the following decomposition whether lossless linking functional dependency and retention.
(1) is provided relational schema S1 (A, B, C) , functional dependencies as F1 = {A → B} incorporated in the R & lt, rho] 1 = {AB, the AC}
(2) provided relational schema S2 (A, B, C), functional dependencies as F2 = {A → C, B → C} set up on the R & lt, [rho] 2 = {AB, the AC}
(. 3) disposed relational schema S3 (A, B, C) , functional dependencies as F3 = {A → B, B → C} in the establishment of R, ρ3 = {AC, BC}
solution: (1) Let R1 = AB, R2 = AC because (R1∩R2) → R1-R2 i.e., A → B, Therefore ρ1 with respect to F1 lossless connection. And because ПAB (F1) ∪ПAC (F1) = {A → B} is equivalent to F1, so that F1 is a holding ρ1 with respect to the decomposition of the functional dependencies.

(2) Let R1 = AB, R2 = AC because (R1∩R2) → R2-R1 i.e., A → C, so that F2 is a non-destructive with respect to ρ2 connection. And because ПAB (F2) ∪ПAC (F2) = {A → C} and F2 are not equivalent, lost B → C, so ρ2 F2 with respect to functional dependency is not maintained.

(3) Let R1 = AC, R2 = BC because (R1∩R2) = C, R1-R2 = A, R2-R1 = B, C → A and C → B are not satisfied, the ρ3 not lossless join with respect F3 . And because ПAC (F3) ∪ПBC (F3) = {B → C) and F3 are not equivalent, so losing the ρ3 A → B relative to F3 do not rely on holding function.

Published 32 original articles · won praise 111 · Views 8154

Guess you like

Origin blog.csdn.net/qq_43688587/article/details/105223366