一、多值依赖的各种定义
定义1:t1,t2,t3形式
A multivalued dependency (MVD) over a relation schema R[U], is an expression of the form X ↠ Y ,where X,Y ⊆ U. An instance I of R[U] satisfies X ↠ Y , denoted by I⊧X ↠ Y ,if for every two tuples t1,t2 in I such that t1[X] = t2[X], there is another tuple t3 in I such that t3[X] = t1[X] = t2[X], t3[Y] = t1[Y], and t3[Z] = t2[Z],where Z = U − XY (XY represents X ∪ Y).
来源:https://link.springer.com/referenceworkentry/10.1007/978-0-38...
在这种定义中,t1,t2,t3必须各不相同,因为如果t1,t2,t3可以相同的话,无法保证分解是无损的。
定义1和定义2是等价的,在定义1中,第一次t1,t2存在一个t3;第二次将t1,t2的位置调换,t2,t1,又将存在一个t3',于是就演变成t1,t2,t3,t4。
定义2:t1,t2,t3,t4形式
2.1表达形式
A Multi-Valued Dependency(MVD) over schema R is a statement of the form X →→ Y where X, Y Í schema(R).
An MVD X →→ Y is satisfied in a relation r over R, denoted by r |= X →→ Y, for all t1, t2 Î r, if t1[X] = t2[X], there exists t3, t4 such that:
1) t1[X] = t2[X]= t3[X] = t4[X],
2) t3[Y] = t1[Y], t3[Z] = t2[Z] and
3) t4[Y] = t2[Y], t4[Z] = t1[Z],
where Z = schema(R) - XY
来源:https://home.cse.ust.hk/~wilfred/dbweb/mvd.html
这个定义没有提及t1,t2,t3,t4是否可以相同,Z是否可以是空集。
2.2表达形式
<<Fundamentals of Database Systems (7th edition)>>,author: Ramez Elmasri,page 475-476:
A multivalued dependency X → Y specified on relation schema R,
where X and Y are both subsets of R, specifies the following constraint on any
relation state r of R: If two tuples t1 and t2 exist in r such that t1[X] = t2[X], then
two tuples t3 and t4 should also exist in r with the following properties19, where we use Z to denote (R − (X ∪ Y))20:
t3[X] = t4[X] = t1[X] = t2[X]
t3[Y] = t1[Y] and t4[Y] = t2[Y]
t3[Z] = t2[Z] and t4[Z] = t1[Z]
19:The tuples t1, t2, t3, and t4 are not necessarily distinct.
20:Z is shorthand for the attributes in R after the attributes in (X ∪ Y) are removed from R.
2.3表达形式
来源:https://turing.cs.hbg.psu.edu/courses/comp419.taw.s97/rdesign...
这种定义充分考虑了多值依赖的对称特性。这个定义不认可"2.2表达形式"的空集场景。
2.4表达形式
国内版本数据库经典教材的表达形式:《数据库系统概论》(第5版)王珊等(ISBN 978-704-040664-1),第186页,对多值依赖的定义:
设R (U)是属性集U上的一个关系模式,X、Y、Z是U的子集,并且Z=U-X-Y。关系模式R(U)中多值依赖X→ → Y成立,当且仅当对R(U)的任一关系r,给定的一对(x,z)值,有一组Y的值,这组值仅仅决定于x值而与z值无关。
下方是一个等价定义:
在R(U)的任一关系r中,如果存在元组t1,t2,使得t1[X] = t2[X],那末必然存在元组t3,t4, 使得t3[X] = t4[X] = t1[X],t3[Y] = t1[Y],t3[Z]=t2[Z],t4[Y] = t2[Y],t4[Z] = t1[Z]
(我使用t1,t2,t3,t4取代原文的s,t,w,v,原文还说,w,v可以和s,t相同。表述仍旧不严谨,w,v可以和s,t相同,那末w可以和v相同吗?s可以和t相同吗)。通过反复阅读该书,我发现该书有表述:"函数依赖可以看作是多值依赖的特殊情况,即若x -> y,则x ->> y。" (第188页),实际上就认可了s=t=w=v可以成立。对比"2.2表达形式",用词极不严谨("2.2表达形式"也有不严谨的地方,但比它更好),下面的讨论围绕"2.2表达形式"展开。
二、进一步的讨论
总结上面的种种定义,我觉得"2.2表达形式"最具有概括性,但是仍有三点让我困惑:
1.t1,t2,t3,t4 are not necessarily distinct
这个定义明确表示tuples t1, t2, t3, and t4 are not necessarily distinct,但是含义仍不明确,t1=t2=t3=t4符合定义吗?t1=t3 and t2=t4也符合定义吗?t1,t2,t3,t4相等的各种组合都符合定义吗?
如果是t1,t2,t3,t4相等的各种组合都符合定义,那末
如果有这样的数据表:
course teacher book
物理 李勇 普通物理
物理 李勇 光学
物理 王军 普通物理
物理 王军 光学
数学 李丽 数学分析
数学 李军 线性代数
course -->> teacher 成立。
当course = 物理,让t1,t2,t3,t4各不相同,当然满足多值依赖的定义;
当course = 数学,让t1,t2,t3,t4全部相等,当然也满足多值依赖的定义。
( x -> y 也可以推出 x --> y,让t1,t2,t3,t4全部相等就自然得出这个结论)
我的观点可以成立吗?
2.Z = R − (X ∪ Y) ,Z可以是空集吗?
如果Z可以是空集,多值依赖的对称性受到破坏。
《数据库系统概论》(第5版)王珊等,p187,认可Z为空集,此时 x->> y 是平凡的多值依赖。
3.多值依赖的无损分解
如果我们认可"2.2表达形式",并且将tuples t1, t2, t3, and t4 are not necessarily distinct理解成,t1,t2,t3,t4相等的各种组合都符合定义,那末无损分解的特性会被破坏。
如果t1,t2,t3,t4必须是完全不同的元组,那末对多值依赖进行分解后,无损分解特性将得到保证。
In other words, for every value of X, the value of attributes in Y is independent of the value of attributes in Z. A multivalued dependency X ↠ Y is a special case of a join dependency expressed as ⋈[XY,X(U − XY)], which specifies that the decomposition of any instance I satisfying ⋈ [XY,X(U − XY)] into π XY (I) and π X(U−XY)(I) is lossless, i.e., I = πXY(I) ⋈ πX(U−XY)(I).
来源:https://link.springer.com/referenceworkentry/10.1007/978-0-38...
关于无损分解:不仅仅指没有信息丢失,如果重新连接分解后的关系,多出原来不存在的元组,那末也是有损的分解。以这个例子中的关系为例,分解成 (course,teacher)、(teacher,book),重新连接会多出原来不存在的元组。这种分解不是无损的,也是有损的。这里的损字是破坏的含义,不是丢失的含义。
我思考了一个星期后得到的认识,请专家斧正一下。