1 / 10

判断一个分解具有无损连接性的算法

判断一个分解具有无损连接性的算法. 算法的输入: 关系模式 R(A 1 ,A 2 ,…,A n ), R 上的函数依赖集 F, R 的一个分解  ={ R 1 ,R 2 ,…,R k }. 算法的输出: true 或 false. 算法 LOSSLESSTEST(R,F ,  ). 构造一个 k 行 n 列的二维表 T ,第 i 行对应于关系模式 R i ,第 j 列对应于属性 A j ,令. a j 若 A j  R i. {. t ij =. b ij 若 A j  R i. c1:=true.

betsy
Download Presentation

判断一个分解具有无损连接性的算法

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 判断一个分解具有无损连接性的算法 算法的输入: 关系模式R(A1,A2,…,An), R上的函数依赖集F, R的一个分解={R1,R2,…,Rk} 算法的输出:true 或 false

  2. 算法 LOSSLESSTEST(R,F ,) 构造一个k行n列的二维表T,第i行对应于关系模式Ri,第j列对应于属性Aj,令 aj若AjRi { tij= bij 若AjRi

  3. c1:=true do while c1 {c1:=false; for 每一个XYF do for 每一对ti,tkT do if ti[X]=tk[X] and ti[Y]tk[Y] then { EQUY(ti,tk); c1=true } }; for 任一个tT do { if t=a1a2..an then return(true)} return(false)

  4. EQUY (ti,tk)是使ti, tk两个元组的Y值相等的子处理过程, 处理原则如下: 若ti[Y]与tj[Y] 有一个为aj 则将另一个也改为aj 否则,tk[Y]=ti[Y] 假定i<k

  5. 例:关系模式 R(A,B,C,D,E) F={AC,BC,CD,DEC,CEA} 分解为 ={R1(A,D),R2(A,B),R3(B,E), R4(C,D,E),R5(A,E )} 用上述算法判断是否具有无损连接性

  6. 构造二维表 A B C D E R1 a1 b12 b13 a4 b15 R2 a1 a2 b23 b24 b25 R3 b31 a2 b33 b34 a5 R4 b41 b42 a3 a4 a5 R5 a1 b52 b53 b54 a5

  7. 由AC,做的修改 A B C D E R1 a1 b12 b13 a4 b15 R2 a1 a2 b23 b13 b24 b25 R3 b31 a2 b33 b34 a5 R4 b41 b42 a3 a4 a5 R5 a1 b52 b53 b54 a5 b13

  8. 由CD做的修改 A B C D E R1 a1 b12 b13 a4 b15 R2 a1 a2 b13 b24 b25 a4 R3 b31 a2 b13 b34 a5 a4 R4 b41 b42 a3 a4 a5 R5 a1 b52 b13 b54 a5 a4

  9. 结果二维表 A B C D E R1 a1 b12 a4 b15 a3 R2 a1 a2 a3 b25 a4 R3 a1 a2 a3 a4 a5 R4 a1 b42 a3 a4 a5 R5 a1 b52 a3 a4 a5 算法输出true 是无损的

  10. 定理:关系模式R(U),分解为={R(U1),R(U2)} 是无损连接的 当且仅当 U1U2 U1-U2 或 U1 U2  U2-U1

More Related