Table of Contents
关系代数的由来
五种基本的关系代数
1、并
2、差(Difference)
3、笛卡儿积(Cartesian Product)
4、投影(Projection)
连接
扩充的代数操作
θ连接
等值连接
自然连接

关系代数

Jun 07, 2016 pm 03:56 PM
one time Algebra relation first

关系代数的由来 首先从宏观上来认识一下关系演算这个概念,换句话讲也就是什么是关系代数,这也是我在接触一些东西的首要工作。大家都知道对于关系型数据库的数据库操作语言分为查询和更新两类。而查询语言这块,又分为关系代数语言与关系演算语言。这里讲的

关系代数的由来

首先从宏观上来认识一下关系演算这个概念,换句话讲也就是什么是关系代数,这也是我在接触一些东西的首要工作。大家都知道对于关系型数据库的数据库操作语言分为查询和更新两类。而查询语言这块,又分为关系代数语言与关系演算语言。这里讲的就是关系代数。所以可以这样定义,关系代数就是为数据库操作语言进行查询的集合操作。

关系代数中的操作可分为两类

(1)传统的集合操作:并、差、交、笛卡儿积、除法。

(2)扩充的关系操作:投影、选择、连接、。

常见符号

\

五种基本的关系代数

1、并

设关系R和S具有相同的关系模式,R和S的并是由属于R或属于S的元组构成的集合,记为R∪S。形式定义如下:喎?http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+UqHIU6HUe3Qg" t∈R ∨ t∈S},t是元组变量,R和S的元数相

\

2、差(Difference)

设关系R和S具有相同的关系模式,R和S的差是由属于R但不属于S的元组构成的集合,记为R-S。形式定义如下:

R-S≡{ t " t∈R ∧ t∈S},R和S的元数相同。

计算机生成了可选文字:关系s1SnoSnameSlleptN00001M田yISN00(X)3CandyISN00004J日匡TlIS关系脸SnoSnameSdeptNo0001M田yISN00008KattefISN00021TOlllIS51一52SnoSnameSllePtN00003气CandyISNo0004Ja匡11ISleseseseseseseseseseses卜

3、笛卡儿积(Cartesian Product)

设关系R和S的元数分别为r和s,定义R和S的笛卡儿积是一个(r+s)元的元组集合,每个元组的前r个分量(属性值)来自R的一个元组,后s个分量来自S的一个元组,记为R×S。

\

4、投影(Projection)

这个操作是对一个关系进行垂直分割,消去某些列,并重新安排列的顺序。

表示符号 π

计算机生成了可选文字:关系黝Sno气snameSdeptNo0001MaryISN00003Can即ISN00004J日以11IS关系s2SnoSnameSlleptN00001MalyISN00008KattCrISNo0021TomIS汀。。,。~(51)SnoSnameN00001MaryN00003CandyN00004J81n

5、连接

这个操作是根据某些条件,对既定的集合进行条件选择。

σ为选择运算符

计算机生成了可选文字:关系s1SnoSname昌几e阵N00001从2卿IS时00003Can即ISN00004J日以nIS关系s2SnoSnameSdePtN00001MaryISN00008KatteYISN00021TOlllIS几彻一*。。。3(51)SnoSnameSdeptN00003CandyIS

对于基本的关系代数操作,可以发现。之前的三种针对的都是两个或者两个至上的集合操作,而后两种操作的都为一个集合。

扩充的代数操作

这个操作就是从两个集合内找出既属于R有属于S集合的元素的集合。符号:∩

如图

计算机生成了可选文字:关系s1SnoSnattteSdcptN00001MalyISN00003CandylSN00004J出nIS关系徽SnoSnameSlleptN00001MaryISN00008KatteYISN00021TomIS51门52SllameSlleptIS0n幻口』气N00001Mary

图中两个集合相同的部分为第一行元素。

除的操作要求进行操作的两个关系集合需要有重叠的属性。

实例图表

计算机生成了可选文字:系,

结果

计算机生成了可选文字:一鱿B一b一R于SAa

连接

所有的连接操作都是在进行笛卡尔积的基础上进行一些相应的条件操作。所以根据条件不同,分为等值连接、自然连接、θ连接。

θ连接

\begin{matrix} R\ \bowtie\ S \\ a\ \theta\ b\end{matrix}

表示从RS中分别选取R的第i列和S的第j列进行连接操作。

等值连接

等值连接就是当θ的值为等于号时的连接。

自然连接

自然连接是一种比较特殊的连接,要求两个连接的关系中必须要有相同的属性。如

计算机生成了可选文字:关系s1SnoSnameSdeptNo0001MalyISNo0003CandyISN00004JalnIS关系s2SttoAgeN00的l23N0000821N00021,,曰7l51)(昌25110SnameSllept叱eN00001、,____气M田甲IS23

如图,两个集合存在相同的属性Sno这样将这两个不同集合中相同属性的一行连接,得到结果。

如上就是关系代数的一些基本操作和扩展操作,更多的需要从实际的例子来理解定义这样会便于理解。对于基本的操作,并、差、笛卡尔积针对的都是两个不同的集合的操作;而投影和连接针对既定集合的操作。扩展中的运算主要是连接,连接根据θ的值的不同来区分到底是自然连接和等值连接;等值连接和自然连接都是θ值在不同情况下的特殊状态。

Statement of this Website
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explore the relationship between the Android system and the Linux kernel Explore the relationship between the Android system and the Linux kernel Mar 14, 2024 pm 12:48 PM

The Android system and the Linux kernel are two closely related entities, and the relationship between them is close and complex. In the Android system, the Linux kernel plays an important role, providing underlying hardware drivers and system call support for the Android system. This article will explore the relationship between the Android system and the Linux kernel, how they interact and work together, and provide some specific code examples. Android is a mobile operating system developed based on the Linux kernel and is mainly used for mobile devices such as smartphones and tablets. L

Research on the relationship between Huawei Hongmeng system and Android Research on the relationship between Huawei Hongmeng system and Android Mar 23, 2024 am 11:54 AM

Research on the relationship between Huawei Hongmeng system and Android With the continuous development of technology, smartphones have become an indispensable part of people's lives. As one of the world's leading mobile phone manufacturers, Huawei has been constantly innovating and is committed to providing better mobile operating systems and user experiences. In recent years, with the United States' suppression of Huawei, Huawei has begun to accelerate the development of its own operating system, and HarmonyOS came into being. In this context, people have begun to pay attention to the relationship between Hongmeng System and Android. First, we need to understand

PHP function introduction—array_values(): returns an array of all elements in the array PHP function introduction—array_values(): returns an array of all elements in the array Jul 26, 2023 pm 04:13 PM

PHP function introduction—array_values(): Returns an array of all elements in the array. In PHP development, array is a very commonly used data structure. PHP provides a wealth of array processing functions, allowing us to operate and process arrays more conveniently. This article will introduce a very practical array function-array_values(), which can return a new array containing all elements in the array. The function of array_values() is to return all elements in the array

The relationship and use of equals(Object) method and hashCode() method in Java The relationship and use of equals(Object) method and hashCode() method in Java Jan 11, 2024 am 10:59 AM

The equals(Object) method and hashCode() method in Java are two important methods used to compare objects for equality. There is a close relationship and interdependence between them, and they play an important role in actual development. First, let's analyze the role of the equals(Object) method. The equals(Object) method is a method defined in the Object class, and all Java classes inherit from the Object class. equals(Obje

CentOS 7 kernel upgrade tutorial. CentOS 7 kernel upgrade tutorial. Feb 18, 2024 pm 05:33 PM

Upgrading the kernel on CentOS7 requires the following steps: Check the current kernel version: Open a terminal and run the following command: uname -r Add ELRepo source: Run the following command to add the ELRepo source: rpm --import Install new kernel: Run the following command to install Latest stable kernel: yum --enablerepo=elrepo-kernelinstallkernel-ml Update boot manager (GRUB) configuration: Run the following command to update the GRUB configuration file: grub2-mkconfig -o/boot/grub2/grub.cfg Restart the system: Run The following command is used to restart the system: reboot verification

In-depth understanding of the relationship between CSS framework and JS In-depth understanding of the relationship between CSS framework and JS Jan 03, 2024 pm 12:13 PM

In-depth understanding of the relationship between CSS framework and JS In modern web development, CSS framework and JavaScript (JS) are two commonly used tools. CSS frameworks can help us quickly build beautiful web pages by providing a series of styling and layout options. JS provides a powerful scripting language that can add interactive and dynamic effects to web pages. This article will delve into the relationship between CSS frameworks and JS and illustrate how they work together with specific code examples. First of all, it needs to be clear that

Entity relationship representation issues in knowledge graph construction Entity relationship representation issues in knowledge graph construction Oct 08, 2023 pm 10:02 PM

Entity relationship representation issues in knowledge graph construction require specific code examples Introduction: With the development of artificial intelligence and big data technology, knowledge graphs have received more and more attention as an effective knowledge organization and representation method. Knowledge graphs represent entities in the real world and the relationships between them in the form of graphs, and can be used for tasks such as natural language processing, machine learning, and reasoning. Entity relationship representation is an important issue in the construction of knowledge graphs. By mapping entities and relationships into vector space, semantic understanding and understanding of entity relationships can be achieved.

Guide to clearing the complex relationship between gods and goddesses in 'Unexpected Duck' Guide to clearing the complex relationship between gods and goddesses in 'Unexpected Duck' Jan 23, 2024 pm 12:30 PM

Unexpectedly, Duck Game is a popular casual puzzle game on Douyin recently. Enter the Douyin APP, then find the game in the search in the upper right corner and click to play to enter the game to experience each level! The game is divided into multiple sections. Among them, one of the levels in Editor-in-Chief Duck’s Selected Section is how to pass the complex relationship between gods and goddesses? Today, the editor of this website brings you a guide to clearing the level of "Unexpected Duck" Fairy Complex Relationship. For those who don't know how to clear this level, please take a look at the picture and text sharing below! "Unexpected Duck" Fairy Complex Relationship Clearance Strategy Fairy Complex Relationship Goal: Complete the relationship diagram 1. Fairy Complex Relationship In this level, we need to drag the following characters to the correct position. There are many characters. 2. The difficulty is too high. It is recommended to give up. Hahahaha 3. The answer is as shown below

See all articles