Relational algebra of databases (theoretical part)

Source: Internet
Author: User

1. Introduction to relational algebra

Relational algebra is an abstract query language and a traditional expression of relational data manipulation language. It expresses queries by relational operations. The calculation object of relational algebra is relational, and the calculation result is also relational 2. relational algebra (1 ). A set operation is generally performed from the perspective of rows. Common Set Operations: and (union) definitions: set the relationship R and relationship s to have n columns of the same number (that is, both links have n attributes), and the corresponding attributes are taken from the same domain, then the relationship between R and S is composed of the tuples that belong to R or S. The result link is still n. Note: R records S = {T | T records R records t records s}. Understanding: first select all the tuples in R and then select the tuples in s that do not belong to R. Example: 2.6 (c) difference (difference) Definition: Set the relationship R and relationship s to have the same object N, and the corresponding attributes are taken from the same domain, then, the difference between relationship R and relationship S is composed of all the tuples belonging to r rather than S. The result link is still n. Written as: R-S = {T | T? r? t? s} example: 2.6 (d) III. Intersection definition: if the relationship R and relationship s have the same object N and the corresponding attributes are taken from the same domain, the relationship R and relationship s are handed over to the tuples that belong to both R and S. The result link is still n. Note: r s = {T | T ∈ R ∧ T ∈ S} example: 2.6 (e) 4. Extended Cartesian Product Definition: the generalized cartesian products of the n-grams and M-objective relations R and S are a set of tuples in the (n + M) column. The first n columns of the tuples are a tuples of the relational R, and the last m column is a tuples of the relational S. If R has K1 tuples and S has K2 tuples, then the generalized Cartesian system of R and S has K1 × K2 tuples.


 

(2) relational operations include selection, projection, join, division, and so on. Selection definition: selection is also called restriction ). It selects the tuples that meet the given conditions in the relational R and records them as follows: F indicates the selection condition. It is a logical expression that obtains the logical value 'true' or 'false '. Note: the basic form of logical expression F is θ, which indicates a comparison operator. It can be >,≥,<, ≤,=, or =. X1 and Y1 are attribute names, constants, and simple functions. The attribute name can also be replaced by its serial number. Phi represents a logical operator, which can be operator, operator, or operator. [] Indicates any option, that is, the part in [] may or may not ,... The preceding format can be repeated. Therefore, the selection operation selects the logical expression F as the true tuples from the relational R. This is an understanding of the operation from the perspective of rows: select some rows

Projection definition: Projection on Relational R is to select several attribute columns from R to form a new relationship. Note: A is an attribute column of R.

Understanding: select some columns. Note: After projection, because identical rows are generated, cancel these identical rows.

Join definition: select the tuples that meet certain conditions between attributes from the Cartesian points of the two relationships. Note: A and B are property groups with the same and comparable degrees on R and S respectively. θ is a comparison operator. The Join Operation selects (R Relation) values and (s relation) on the attribute group from the Cartesian Product R × S of R and S) the tuples in the B attribute group that have values that satisfy the comparison relation θ. Understanding: select some rows that meet certain conditions from Descartes. Note: ① There are two most important and commonly used connections in connection operations: equi-join and natural join ). ② The Join Operation with θ as "=" is called an equijoin. It selects the tuples whose values of A and B are equal from the Cartesian points of the relationship R and S. That is, the equijoin is: ③ natural join is a special equijoin, which requires that the components for comparison in the two relations must be the same attribute group, duplicate attributes must be removed from the results. That is, if R and S have the same attribute group B, the natural connection can be recorded as: Division (Division) Definition: Given relations R (x, y) and S (Y, Z ), x, Y, and Z are attribute groups. Y in R and Y in S can have different attribute names, but must come from the same domain set. The division operation between R and S generates a new relationship p (x). P is the projection of tuples in R that meet the following conditions on the X attribute column: X indicates the image set Yx of X, which is the value of X on X. It contains the set of S projection on Y. Note: Yx is the image set of X in R,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.