search
HomeCommon ProblemWhat are the relational operations in relational databases?

What are the relational operations in relational databases?

#What are the relational operations included in relational databases?

1. Selection operation, select all tuples that meet the given conditions from a relation R;

2. Projection operation, select a certain attribute from all attributes of a relation R Some specified attributes;

3. Connection operation is to select tuples that meet certain conditions between attributes from the generalized Cartesian product of two relationships to form a new relationship.

Relational operations

There are two types of basic relational operations: one is the traditional set operation (union, difference, intersection, etc.), and the other is specialized Relational operations (selection, projection, connection, division, outer join, etc.). Some queries require a combination of several basic operations and require several steps to complete.

1. Traditional set operations

1. UNION There are two relations R and S, which have the same structure. The union of R and S is a set consisting of tuples belonging to R or belonging to S, and the operator is ∪. Marked as T=R∪S.

2. Difference (DIFFERENCE) The difference between R and S is a set composed of tuples that belong to R but not

to S. The operator is -. Marked as T=R-S.

3. INTERSECTION The intersection of R and S is a set composed of tuples that belong to both R and S. The operator is ∩. Denote it as T=R∩S. R∩S=R-(R-S).

2. Selection operation

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

For example: LIST FOR publishing unit='Higher Education Press' AND unit price

3. Projection operation

Select several attributes from the relationship model to form a new The relationship is called projection. This is done from a column perspective and is equivalent to a vertical decomposition of the relationship. The phrase FIELDS is equivalent to the projection operation in FOXPRO. For example: LIST FIELDS Unit, name

4. Connection operation

The connection operation is to select tuples that meet certain conditions between attributes from the Cartesian product of two relationships.

5. Division operation

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

Suppose the division relation R is an m-ary relation, and the division relation S is an n-ary relation, then their quotient is an m-n-ary relation, recorded as R÷S. The principle of quotient composition is: divide the m-n columns in the division relationship R into several groups according to their values, check whether the set of n column values ​​in each group contains the division relationship S, and if so, take the value of the m-n column as the quotient. A tuple, otherwise not taken.

Recommended tutorial: "MySQL Tutorial"

The above is the detailed content of What are the relational operations in relational databases?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool