当前位置:网站首页>Relational algebra of tyut Taiyuan University of technology 2022 database
Relational algebra of tyut Taiyuan University of technology 2022 database
2022-07-06 13:12:00 【Lala Lulu^_^】
There are two models for this problem :
The first is to give you numbers 、 Groups of tables of letters or attributes , Let you use relational algebra
The second is to give “ Relational database schema ”, Let's use it “ Relational algebra expression ” Represents various queries , It is more difficult than the first
Random this year
Let's take a brief look at the concept :
One 、 Relational database schema : Short for R(A1,A2,~~~An),R Name the relationship ,A For the property name
eg: company ( Company number 、 Company name 、 Address )
eg:S (S#,SNAME,AGE,SEX)( Some relationship models will be in pure English )
Two . Relational algebra expression :
hand over n、 and U、 Bad -( In high school , A little )、 The cartesian product x、 choice σ、 Projection Π、 Connect 
The cartesian product :
S: | T: | |||||
A | B | A | B | |||
3 | 4 | 1 | 5 | |||
7 | 2 | 3 | 6 |
be SxT=
| S.A | S.B | T.A | T.B |
| 3 | 4 | 1 | 5 |
| 3 | 4 | 3 | 6 |
| 7 | 2 | 1 | 5 |
| 7 | 2 | 3 | 6 |
Cartesian product is an operation in horizontal direction , Each row of the first table is connected to each row of the second table
choice σ:
grammar :σ+ Conditions ( The table queried )
eg: goods ( goods ID, Name of commodity , Price , brand , model , Color , manufacturer , Place of Origin )
Check the commodity information of Shanghai origin :σ Place of Origin =‘ Shanghai ’ ( goods )
choice It is a horizontal query , The result is all the attributes of qualified goods ( Remember to add single quotation marks to the string )
Projection Π:
eg: goods ( goods ID, Name of commodity , Price , brand , model , Color , manufacturer , Place of Origin )
Inquire about the goods produced in Shanghai ID, Name of commodity :Π goods ID, Name of commodity (σ Place of Origin =‘ Shanghai ’( goods ))
Projection is a vertical query , The result is a single attribute
Connect :
Connections are generally used for tables , There is a natural connection 、 External connection 、 Left connection 、 The right connection . The teacher won't embarrass us , There are only natural connection questions in the question bank , So just talk about the simplest natural connection


As shown above , Connection is to perform Cartesian operations on rows with the same attributes in two relationships
except :


In the last question R As divisor ,S As divisor
Method :(1) Find out first R、S Common attributes in B、C
(2) Then find the dividend R There are attribute values and S There are rows with the same attribute value ,
namely R(2):
| A | B | C |
| a1 | b1 | c2 |
| a1 | b2 | c3 |
| a2 | b2 | c3 |
| a1 | b2 | c1 |
(3) Remove the second step table R(2) Common attribute column in B、C, Just stay A Column
namely
| A |
| a1 |
| a1 |
| a2 |
| a1 |
Simplify to 
Master these basic concepts , We can do questions ,SQL There are many ways to query , So the answers to many questions are not unique .
example 1: The real question 
Explain :1.
example 2、

Explain :


example 3、

Explain :

边栏推荐
- [algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire
- TYUT太原理工大学2022软工导论考试题型大纲
- Small exercise of library management system
- 【话题终结者】
- [Chongqing Guangdong education] reference materials for regional analysis and planning of Pingdingshan University
- 167. Sum of two numbers II - input ordered array - Double pointers
- Alibaba cloud microservices (I) service registry Nacos, rest template and feign client
- [algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix
- How do architects draw system architecture blueprints?
- Interview Essentials: talk about the various implementations of distributed locks!
猜你喜欢

One article to get UDP and TCP high-frequency interview questions!

十分钟彻底掌握缓存击穿、缓存穿透、缓存雪崩
![[algorithm] sword finger offer2 golang interview question 1: integer division](/img/e6/f17135207b3540ec58e5a9eed54220.png)
[algorithm] sword finger offer2 golang interview question 1: integer division

Role movement in the first person perspective
![[algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire](/img/c2/6f6c3bd4d70252ba73addad6a3a9c1.png)
[algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire

【无标题】

MYSQL索引钟B-TREE ,B+TREE ,HASH索引之间的区别和应用场景

TYUT太原理工大学2022数据库之关系代数小题

阿里云微服务(四) Service Mesh综述以及实例Istio

阿里云微服务(一)服务注册中心Nacos以及REST Template和Feign Client
随机推荐
闇の連鎖(LCA+树上差分)
[算法] 剑指offer2 golang 面试题1:整数除法
[algorithm] sword finger offer2 golang interview question 6: sum of two numbers in the sorting array
[算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数
系统设计学习(一)Design Pastebin.com (or Bit.ly)
Fgui project packaging and Publishing & importing unity & the way to display the UI
Redis介绍与使用
TYUT太原理工大学2022数据库考试题型大纲
[算法] 剑指offer2 golang 面试题5:单词长度的最大乘积
Usage differences between isempty and isblank
WSL common commands
2022国赛Re1 baby_tree
TYUT太原理工大学2022数据库大题之E-R图转关系模式
[algorithm] sword finger offer2 golang interview question 7: 3 numbers with 0 in the array
XV Function definition and call
Realization of the code for calculating the mean square error of GPS Height Fitting
Comparative analysis of the execution efficiency of MySQL 5.7 statistical table records
Record: I accidentally wrote a recursion next time
[algorithm] sword finger offer2 golang interview question 9: subarray with product less than k
Exception: ioexception:stream closed