The concept of the description of the very abstract, just beginning to learn the students completely unintelligible. Here, an example is given to illustrate the process of solving the division operation.
With the relationship R, S, the result of seeking R÷s
Solution Step Procedure:
The first step: find the Relationship R and the same attribute in the relationship s, that is, the Y property. Make a projection of y in relation s (to be taken out of the Y column), and the result is as follows
The second step: the attribute column in the R that is not the same as in S is X, and the relationship R does a projection of the de-duplicated value on the attribute (X) to {x1,x2};
Step three: Find the X attribute of the relationship r in the corresponding image set Y
According to the records of the relationship R, the records related to the X1 value can be obtained, as shown in 3; records related to X2, as shown in Figure 4
Fourth step: Judging the inclusion relationship
R÷s is actually determining whether the set Y of x values in the relationship R contains all the values of the attribute y in the relationship s. Compare to discover:
The X1 image set is only Y1 and cannot contain all the values of the attribute y in the relationship s, so the X1 is ruled out;
And X2 's image set contains all the values of attribute y in relation s, so the r÷s end result is X2,
Maybe now you know a little bit about how the division operation is done, so let's take a look at what the division can solve.
Take a look at the following small example:
With relationship R,s and RS, for rs÷s results
It's easy to get the result: {Zhang San}
So you can easily see that the problem that rs÷s is solving here is: "Students who have enrolled in all courses."
The meaning of Rs÷s is: "In the contact RS of R and S, find the R tuples that are related to all tuples in S."
Division operations in Relational algebra