"Database system Concept" 8-selection, projection and other relational operations

Source: Internet
Author: User
Tags lowercase

In the relational algebra relational algebra, the unary operator has the option of selecting, projecting project, renaming Remane, the remainder including the union, set difference set diffetence, and Cartesian product Cartesian Product, etc., is a two-element operator. Learn the basics of their use below.
One or one-tuple operator
A) Select
The selected operator is lowercase sigma (σ), such as a teacher selecting a physics department, which can be written as:
Σdept_name= "Physics" (instructor) (The standard notation dept_name= "Physics" belongs to the subscript of σ).
You can also use comparison operations, with ∧, or ∨, non-, and so on, with salaries greater than 90000 of the physics faculty:
Σdept_name= "Physics" ∧salary>90000 (instructor)
The department name is the same as the part of the office building where:
Σdept_name=building (department)
It is important to note that the select in relational algebra does not correspond to the select in SQL, which corresponds to the WHERE clause of SQL
b) Projection
The projection operator is the uppercase Pi (Π), which can optionally display some properties of the relationship, SQL's Select ID, name, salary from instructor can be represented as:
Πid, name, salary (instructor)
c) combination of relational operations
The result of a relational operation is still a relationship, and based on this, a combination of relational operations can be used, such as finding the name of the teacher in the physics department, which can be expressed as:
Πname (σdept name = "Physics" (instructor))
Here, the result of the selection operation is used as the parameter of the projection operation.
d) renaming
The renamed symbol is lowercase rho (ρ):
Ρx (e) means to rename the relationship E to X
Ρx (A1,a2 ...) (e) the attribute corresponding to E is also renamed to A1,A2 ...
Two or two-tuple operator
A) and OP union
The two-tuple operator is used to combine two collections of the same structure, and the course IDs that were previously queried for the fall of 2009 and Spring 2010 can be expressed as:
Πcourse ID (semester = "Fall" ∧year=2009 (section))

Πcourse ID (semester = "Spring" ∧year=2010 (section))
The symbol for the union operation is ∪, and the relationship that participates in the Union must have the same number of attributes, and the attribute type must be the same for the merge bit.
b) Set difference operation Set-difference
The sign bit of the set difference operation minus-,r-s results in tuples that exist in R but do not exist in S. The set difference operation requires the same set as the Union.
c) Cartesian product Cartesian product
The x,instructorxteaches of the Cartesian product is the result of all possible combinations between the teacher and the curriculum, but this often has little practical significance, except for the tuples that teachers and courses can correspond to, which can be filtered as:
Σinstructor. ID = teaches.instcuctor_id (Dept name = "Physics" (instructorxteaches))


Learning materials: Database System concepts, by Abraham Silberschatz, Henry F.korth, S.sudarshan


?

"Database system Concept" 8-selection, projection and other relational operations

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.