Functional dependency model of mad science database design issues and data

Here Insert Picture Description

A. Relational schema design issues

1.1 data dependencies

Relational database isRelational ModelBased database that uses a relationship described in the real world. Can describe a relationship between an entity and its attributes used, it can also be used to describe a link between the entities. Relational schema is used to define a relationship, a relational database contains a set of relationships defining a relationship model of the set of all relations constitute the model database.
The core issue is the relationship between modeData dependenciesThe data dependency constraint is likely to be the current value of those relational schema relationship, is the interdependence between attributes (attributes or group) and attribute (or attribute group) in a relationship, there is an objective of the semantics.
Data dependence is through a relationship between property values depend on whether or not reflect the relationships between data, it is an abstraction between the physical properties of inter-related world, is the inherent nature of the data, is the embodiment of semantics.
The most important thing isFunctional Dependencies (Functional Dependency,FD)和Multivalued dependency(Multivalued Dependency, MVD)。

1.2 Effects on the data dependence relation mode

Functional Dependencies generally exist in real life. For example, a description of the relationship between students can learn numbers (Sno), name (Sname), where the Department (Sdept) and several other properties. Because a student number corresponds to only one student, a student in only one department. Thus when the "study" to determine the value, the value of the name and location system will be uniquely identified. This function mathematics dependencies between attributes similar .

Ideal model should not happenAbnormal insertion, deletion anomalies, update anomalies, data redundancyAs few as possible. The reason why a relationship pattern will produce the above problems, is dependent on the presence of certain patterns in the data caused.Normalization theoryIt is used toThe transformation of the relationship model, relational schema by decomposingWhich is inappropriate to eliminate data dependencies to address anomalies insert, delete abnormal, update anomalies and data redundancy issues

II. Functional Dependency Data

2.1 Functional Dependencies

2.1.1 defines functional dependencies

R & lt set (U) is the relational model to the attribute set U, X, Y is a subset of U. r is an arbitrary R (U) in a given relation. If any two tuples r to s and t, where s [X] = time t [X-], there is s [Y] = t [Y], calledFunction to determine a subset of attributes X or Y, said subset of the properties depends on the function X Y, Otherwise known as X or Y is not a function of the decision, said Y function is not dependent on X.

  1. If Y is a function dependent on X, is referred to as X → Y.
  2. If X → Y, then X is the determining factor (determinant).
  3. If the X → Y, and Y → X, is referred to as X ← → Y.
  4. If Y is not functionally dependent on X, then referred to as X↛Y.

For example, in learning lives:

学号→姓名(每个学号只能有一个学生姓名) 
学号→系别(每个学号只能在一个系) 
学号→图书证号(每个学号只能有一个图书证号) 
系别→系主任(每个系只能由一名系主任

2.1.2 case three basic functional dependencies

(1) a non-trivial dependence and trivial function

If the X → Y, but Y is not a subset of X, X → Y is said non-trivial functional dependency (nontrivial functional dependency), Generally discuss nontrivial

在关系 SC(Sno,Cno,Grade)中,
非平凡函数依赖:(Sno,Cno) →Grade

If the X → Y, where Y is a subset of X, X → Y is called a trivial function dependent (nontrivial functional dependency)

在关系 SC(Sno,Cno,Grade)中
平凡函数依赖:(Sno,Cno) →Sno;(Sno,Cno) →Cno

(2) partially and fully functional dependency
If X → Y, but for any X is a subset X ', Y are not dependent on the X', Y claimed completely dependent,Referred to as XF → Y

在关系 SC(Sno,Cno,Sname,Grade)中,
 完全函数依赖: (Sno,Cno) →Grade

If the X → Y, where Y is not completely dependent on the X function, the X-Y portion called functional dependencies,Referred to as XP → Y

在关系 SC(Sno,Cno,Sname,Grade)中,
部分函数依赖:(Sno,Cno) → Sname

(3) transfer function depends directly

In R (U), if the X → Y, (Y⊈X), Y↛X, Y → Z, called the X-Z-dependent transfer function. DenotedX  transfer →  Z. Plus conditions Y↛X, because if Y → X, then X ← → Y, is actually directly == X  → Z ==, i.e. not directly dependent function dependent transfer function.

指出关系 S (学号,姓名,图书证号,系别,系主任)中存在的传递函数依赖。 
传递函数依赖:学号→系别, 系别→系主任,系主任传递函数依赖于学号

2.2 functional dependencies and code (keywords) Contact

Code is in relational schema R can uniquely identify a tuple attribute or group of attributes.

From the perspective of the function dependence, the formal definition given code. Let K relational schema R <U, F> or the attribute property group,If the K F → U R K is the candidate code (Candidate Key), also referred to as code (Key)

Relational Schema each candidate code has the following two characteristics:
(1) Uniqueness : Let R in (the U-), K is the candidate code R, a relation r for any relational schema corresponding to R, the candidate does not exist same code attribute values of two tuples, i.e., the value of the candidate code is unique.
(2) minimum characteristic : in the relationship between R mode (the U-), K is the candidate code R, in the case where the uniqueness of the candidate code is not damaged, no attribute deleted from the candidate code inside.


设 R(A,B,C,D,E),F={AB→CDE,E→ABCD},确定 R 的主属性及非 主属性。
解:该关系模式有 2 个候选码:AB,E。所以 A、B、E 是主属性,C、D 是非主属性。

2.3 Minimum functional dependencies

Functional dependencies F contains several functional dependencies, in order to obtain the most streamlined functional dependencies, should 去掉其中平凡的,无关的函数依赖和多余的属性.
conditions :

(1)F 中的每一个函数依赖的依赖因素(右边)只含有单个属性。
(2)F中没有冗余的函数依赖,即在F中不存在这样的函数依赖X→Y,使得F与F-{X→Y} 等价。
(3)每个函数依赖的左边没有冗余的属性,即 F 中不存在这样的函数依赖 X→Y,X 有真 子集 W 使得 F-{X→Y}{W→Y}与 F 等价。

With relational schema R (U, F), where U = {A, B, C, D, E, G), F = {AD → E, AC → E, BCD → AG, AB → G, A → C }, the minimum required functional dependencies F?

The first step: all the dependent factor F in into a single property. AD → E, AC → E, BCD → A, BCD → G, AB → G, A → C
Step: remove the redundancy function F dependent. (
1) Since F is removed AD → E, to give Fl = {the AC → E, the BCD → A, the BCD → G, AB → G, A → C}, the AD Fl + = ACDE , comprising E, so that the functional dependency is redundant It may be removed from F to.
(2) Since the F1 is removed AC → E, to give F2 of = {the BCD → A, the BCD → G, AB → G, A → C}, the AC F2 of + = the AC , does not include E, so that the functional dependency is not redundant, It can not be removed from F1.
(3) Since the F1 is removed BCD → A, to give F3 = {the AC → E, the BCD → G, AB → G, A → C}, the BCD F3 + = BCDG , does not contain A, this functional dependency is not redundant and can not be removed from F1.
(4) Since the F1 is removed BCD → G, to obtain the F4 = {the AC → E, the BCD → A, AB → G, A → C}, the BCD the F4 + = ABCDEG , comprising G, so that the functional dependency is redundant, can removed from F1.
(5) Since F4, removing AB → G, have F5 = {AC → E, BCD → A, A → C}, ** AB F5 + **  = ABCE, does not contain G, so that the functional dependency is not redundant , can not be removed from the F4.
(6) Since the removed F4 A → C, to give the AC → E {= F6, the BCD → A, G → AB}, A = A + F6, Does not contain C, with the functional dependency is not redundant and can not be removed from F4. Thus, F4 = {AC → E, BCD → A, AB → G, A → C}.
The third step: remove all redundant attributes determining factor in the F4. The method is to remove a property in which a determining factor in whether the decision was still able to look at dependent factors.
(1) The AC → E, if A is removed, the closure is free C E, it is not redundant attributes A, can not be removed; if the C is removed, the closure comprising A E, it is redundant attributes C, can be removed.
(2) The BCD → A, if B is removed, the closure of the CD does not contain A, B it is not redundant properties, can not be removed; Similarly C and D are not redundant attributes.
3) AB → G, if A is removed, the closure does not contain B G, it is not redundant attributes A, it can not be removed, nor redundant Similarly B properties. therefore,Fm={A→E,BCD→A,AB→G,A→C}

Conclusion:
F. And its minimum functional dependencies are equivalent.
Since the process of solving the relationship between properties and functions of the processing sequence dependent, and
thus each of the functional dependencies F is not necessarily only a minimal functional dependencies!

END!!!
Here Insert Picture Description

Published 32 original articles · won praise 111 · Views 8153

Guess you like

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