Traditional Culture Encyclopedia - Traditional festivals - Steps of relational operation

Steps of relational operation

First, the traditional set operation.

1 and UNION have two relations, R and S, which have the same structure. The union of R and S is a set of tuples belonging to R or S, and the operator is ∨. Write t = r ∪ s.

2. The difference between R and S is a set of tuples belonging to R but not S, and the operator is-. Write it down as t = r-s.

3. Intersection The intersection of R and S is a set of tuples belonging to both R and S, and the operator is ∩. Write it as t = r ∩ s. R∩S=R-(R-S).

Second, select the operation

Finding tuples from relationships that meet given conditions is called selection. The condition is given by a logical expression, and a tuple with a true value will be selected. This operation extracts tuples from the horizontal direction. In FOXPRO, FOR and WHILE are equivalent to selection operations.

For example, list of publishing units =' Higher Education Press' and unit price.

Third, the projection operation

Selecting several attributes from the relational schema to form a new relationship is called projection. This is an operation from the perspective of columns, which is equivalent to the vertical decomposition of relations. In FOXPRO, the word FIELDS is equivalent to projection operation. Such as: list field unit, name

Fourth, the connection operation

The join operation is to select tuples whose attributes meet certain conditions from the Cartesian products of two relations.

Verb (abbreviation for verb) division operation

In relational algebra, division can be understood as the inverse of cartesian product.

Let the divided relation R be an m-ary relation and the divided relation S be an n-ary relation, then their quotient is an m-n-ary relation, which is denoted as r÷s. The principle of forming quotient is: divide the m-n columns in the divided relation R into several groups according to their values, and check whether the set of n-column values in each group contains the divided relation S, if so, take the values of the m-n columns as tuples of quotient, otherwise don't take them.

Six, external connection operation