"Database Review" relational algebra __ Database

Source: Internet
Author: User
Tags expression min

Relational Algebra

Q: Why is it called algebra?

A: Because there are operators and operands, the operand is a table, the operator is the intersection, and so on;

Relational algebra is divided into set-based relational algebra and packet-based relational algebra;



The basic operation of relational algebra: and, Selection, projection, Cartesian product, difference, renaming;

The basic operation means that other operators can be launched by basic operation;


Note: If we use the and, intersection, and difference operations, we must ensure that the properties set of R and S are the same, and of course, if they are different, they can also be renamed;


Add:

1. Natural Connection

  

2.θ Connection


3. renaming


An expression tree


Packet-based relational algebra

1. and

If the tuple T appears in R for M times and N times in S, it appears m+n times in R∪s;

2. Pay

If the tuple T appears in R for M times and N times in S, then min (m,n) appears in R∩s;

3. Poor

If the tuple T appears in R for M times and N times in S, then the r-s appears (1) if m>n, the m-n occurs; (2) if m<n, 0 times;

4. Eliminate duplicate operators

Δ (R) can eliminate repeating tuples on relation R;


5. Aggregation Operators

SUM (A)

AVG (A)

MIN (A)

MAX (A)

COUNT (A)

Where A is a property;

6. Grouping operators

Gamma

Contains a property as a grouping attribute, and an aggregation operator;


7. Sorting tuples

Τa (R) means sorting according to the A attribute;


8. External connection

left outer connection:

right outer connection:

9. Extended Projection Operations



Step representations of relational algebraic expressions

Because it is not clear that a complex algebraic expression is represented directly by an expression, we can express it in steps.

Like what:

Can be expressed as:

 

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.