[Database Principles] Relational Database Theory (4)

An overview of the decomposition relationship model.

An example of a general pattern is given in relational database theory (1) :
Insert picture description here
a relational pattern like this does not clearly analyze the dependency relationship between attributes, but generally includes all the attributes that appear. For this kind of In relational mode, its own data structure contains many fatal problems. Modification, insertion and deletion of data will cause inconvenience and even errors.
These problems can be solved by decomposing the relational model. In the relational database theory (1) , we also give an example of decomposition. Simply put, decomposition is the use of projection operations in relational algebra operations to disassemble a relational pattern into multiple. From the perspective of relational examples, it is to replace the original complex table with multiple small-scale tables, so that each small The data structure of the scale table is more reasonable, avoiding inconvenience and errors in actual use.

Schema decomposition definition.

Insert picture description here
The current value r corresponding to the universal relational pattern R(U) is called the universal relation. After we make a decomposition, we need to consider: the data is stored in the database σ, then whether σ and r at this time represent the same database? If it is not, then this decomposition is meaningless, because the decomposition has led to the loss of some data.
This question needs to be considered from the following two perspectives:

  • Whether σ and r are equivalent, that is, whether they represent the same data, this question is expressed by the characteristic of [lossless connection];
  • There is a functional dependency set F on the relational pattern R(U), and each relational pattern R i R_i in ρRiThere is a functional dependency set F i F_iFi, Then { F 1, F 2,..., F k F_1,F_2,...,F_k F1,F2,...,Fk} Is it equivalent to F? This question is expressed by the feature of [maintain functional dependence].

It can be seen that the decomposition of the relational model is not only the decomposition of the data set, but also the decomposition of the functional dependency set on the relational model and the current value (relational instance) of the relational model. Therefore, to measure whether the decomposition of a relational model is desirable, there are two main criteria:

  1. Whether it has a lossless connection;
  2. Whether to maintain functional dependencies.

★Test the lossless connection.

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Quick test for special circumstances.

When there are only two relational modes in ρ, that is, ρ={ R 1, R 2 R_1, R_2 R1,R2}, there is a quick test method. Although the above general method is not too slow.
Insert picture description here

Keep functional dependency decomposition.

If the functional dependency cannot be maintained during the decomposition process, the semantics of the data may be confused.
Insert picture description here
It can be seen from the definition that the decomposition of maintaining functional dependence is to decompose R into R 1, R 2,..., R k R_1,R_2,...,R_kR1,R2,...,RkLater, the functional dependency set F should be implied by the projection of F on these small relational patterns. Because the functional dependency in F is actually the integrity constraint of the relational model R, F must be maintained after R is decomposed, otherwise the integrity will be destroyed.
But we need to note that a lossless connection decomposition is not necessarily functionally dependent, and a functionally dependent decomposition is not necessarily lossless, and the two do not determine each other.

Guess you like

Origin blog.csdn.net/weixin_44246009/article/details/108103664