数据库中关系代数是什么_什么是关系代数?

更新时间:2023-06-04 01:04:09 阅读: 评论:0

数据库中关系代数是什么_什么是关系代数?
数据库中关系代数是什么
Every databa management system must define a query language to allow urs to access the data stored in the databa. Relational Algebra is a procedural query language ud to query the databa tables to access data in different ways. Relational Algebra
关系代数是⼀种过程查询语⾔,⽤于查询数据库每个数据库管理系统都必须定义⼀种查询语⾔,以允许⽤户访问存储在数据库中的数据。 关系代数
表以不同⽅式访问数据。
In relational algebra, input is a relation(table from which data has to be accesd) and output is also a relation(a temporary table holding the data asked for by the ur).
在关系代数中,输⼊是⼀个关系(必须从中访问数据的表),⽽输出也是⼀个关系(⼀个保存⽤户要求的数据的临时表)。
Relational Algebra works on the whole table at once, so we do not have to u loops etc to iterate over all the rows(tuples)杜牧的诗有哪些
of data one by one. All we have to do is specify the table name from which we need the data, and in a single line of command, relational algebra will traver the entire given table to fetch data for you.
关系代数可⼀次在整个表上⼯作,因此我们不必使⽤循环等来遍历数据的所有⾏(元组)。 我们要做的就是指定要从中获取数据的表名,并且在单⾏命令中,关系代数将遍历整个给定表以为您获取数据。
一线城市有哪些The primary operations that we can perform using relational algebra are:
我们可以使⽤关系代数执⾏的主要运算是:
1. Select
选择
2. Project
项⽬
3. Union
联盟
4. Set Different
设置不同
5. Cartesian product
笛卡尔积
6. Rename
改名
选择运算(σ) (Select Operation (σ))
This is ud to fetch rows(tuples) from table(relation) which satisfies a given condition.
这⽤于从满⾜给定条件的表(关系)中获取⾏(元组)。
Syntax:Syntax: σp (r)
语法:语法: σ p  (r)
Where, σ reprents the Select Predicate, r  is the name of relation(table name in which you want to look for data), and p  is the prepositional logic, where we specify the conditions that must be satisfied by the data. In prepositional logic, one can u unary unary and binary binary operators like =, <, > etc, to specify the conditions.
其中, σ表⽰选择谓词, r 是关系的名称(要在其中查找数据的表名), p 是介词逻辑,我们在其中指
定数据必须满⾜的条件。 在介词逻辑中,可以使⽤⼀元⼀元和⼆进制⼆进制运算符(例如= , < , >等)来指定条件。
Let's take an example of the Student table we specified above in the Introduction of relational algebra, and fetch data for students students with age age more than 17.
让我们以上⾯在关系代数简介中指定的Student表为例,并获取年龄年龄⼤于17 岁的岁的 学⽣的学⽣的数据。
σage > 17 (Student)
σ age > 17 (Student)
This will fetch the tuples(rows) from table Student Student, for which age age will be greater than 1717.
这将从表Student中Student中获取元组(⾏),其年龄年龄将⼤于1717 。
You can also u, and , or  etc operators, to specify two conditions, for example,
您还可以使⽤and  or  etc运算符来指定两个条件,例如,
σage > 17 and gender = 'Male' (Student)
σ age > 17 and gender = 'Male' (Student)
This will return tuples(rows) from table Student Student with information of male students, of age more than 17.(Consider the Student table has an attribute Gender  too.)
这将返回“ 学⽣”学⽣”表中的元组(⾏),其中包含年龄⼤于17岁的男学⽣的信息(考虑“学⽣”表也具有“ Gender 属性。)
项⽬运作(∏) (Project Operation (∏))
Project operation is ud to project only a certain t of attributes of a relation. In simple words, If you want to e only the names names all of the students in the Student Student table, then you can u Project Operation.
项⽬操作仅⽤于投影关系的特定属性集。 简⽽⾔之,如果您只想在“ 学⽣”学⽣”表中看到所有学⽣的姓名姓名 ,则可以使⽤“项⽬操作”。It will only project or show the columns or attributes asked for, and will also remove duplicate data from the columns.它只会投影或显⽰所需的列或属性,还将从列中删除重复的数据。
Syntax:Syntax: ∏A1, A2...(r)
语法:语法: ∏ A1, A2... (r)
where A1, A2 etc are attribute names(column names).
其中A1,A2等是属性名称(列名称)。
For example,
例如,
∏Name, Age(Student)
∏Name, Age (Student)
Age columns for all the rows of data in Student
Student table.
Name and Age
Above statement will show us only the Name
Name和Age
Age列。
Student表中所有数据⾏的Name
上⾯的语句仅向我们显⽰Student
联盟运作(∪) (Union Operation (∪))
This operation is ud to fetch data from two relations(tables) or temporary relation(result of another operation).
此操作⽤于从两个关系(表)或临时关系(另⼀个操作的结果)中获取数据。
For this operation to work, the relations(tables) specified should have same number of attributes(columns) and same attribute domain. Also the duplicate tuples are autamatically eliminated from the result.
为了执⾏此操作,指定的关系(表)应具有相同数量的属性(列)和相同的属性域。 同样,从结果中⾃动删除重复的元组。
Syntax: A ∪ B
Syntax:
语法: A ∪ B
语法:
where A and B are relations.
其中A和B是关系。
student to save name of student,
ExtraClass, both have a column student
For example, if we have two tables RegularClass
RegularClass and ExtraClass
then,
Student来保存Student的名称,那么,
例如,如果我们有两个表RegularClass
ExtraClass ,它们都有⼀个列Student
RegularClass和ExtraClass
∏Student(RegularClass) ∪∏Student(ExtraClass)
∏Student (RegularClass) ∪∏Student (ExtraClass)
Students who are attending both regular class and extra class, eliminating Above operation will give us name of Students
repetition.
通过上述操作,我们可以为参加常规课程和额外课程的学⽣
学⽣取名,从⽽避免重复学习。
设置差异(-) (Set Difference (-))
This operation is ud to find data prent in one relation and not prent in the cond relation. This operation is also applicable on two relations, just like Union operation.
此操作⽤于查找以⼀种关系存在⽽不以第⼆种关系存在的数据。 就像联合运算⼀样,该运算也适⽤于两个关系。
Syntax: A - B
Syntax:
语法: A - B
语法:
where A and B are relations.
其中A和B是关系。
For example, if we want to find name of students who attend the regular class but not the extra class,
then, we can u the below operation:
例如,如果我们要查找参加普通班⽽不是额外班级的学⽣的姓名,则可以使⽤以下操作:
∏Student(RegularClass) - ∏Student(ExtraClass)
红色婚纱
∏Student (RegularClass) - ∏Student (ExtraClass)
笛卡尔积(X) (Cartesian Product (X))
This is ud to combine data from two different relations(tables) into one and fetch data from the combined relation.
这⽤于将来⾃两个不同关系(表)的数据组合为⼀个,并从组合关系中获取数据。
Syntax: A X B
Syntax:
语法:
语法: AXB
For example, if we want to find the information for Regular Class and Extra Class which are conducted during morning, then, we can u the following operation:
例如,如果我们想查找早晨进⾏的常规班和额外班的信息,则可以使⽤以下操作:
第七套广播体操σtime = 'morning' (RegularClass X ExtraClass)
σtime = 'morning' (RegularClass X ExtraClass)
time.
ExtraClass should have the attribute time
For the above query to work, both RegularClass
RegularClass and ExtraClass
ExtraClass都应具有属性time
time 。
西安三本为了使以上查询正常⼯作, RegularClass
RegularClass和ExtraClass
重命名操作(ρ) (Rename Operation (ρ))
This operation is ud to rename the output relation for any query operation which returns result like Select, Project etc. Or to simply rename a relation(table)
辅警工作总结此操作⽤于重命名返回查询(如Select,Project等)的任何查询操作的输出关系。或者仅重命名关系(表)
Syntax:
Syntax: ρ(RelationNew, RelationOld)
语法: ρ(RelationNew, RelationOld)
股东退股协议
语法:
Join operations like,
Apart from the common operations Relational Algebra is also ud for Join
除了这些常见的运算,关系代数还⽤于Join
Join运算,例如,
Natural Join
⾃然加⼊
Outer Join
外连接
Theta join etc.
Theta连接等
河北教师继续教育数据库中关系代数是什么

本文发布于:2023-06-04 01:04:09,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/854017.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:关系   代数   数据   操作   数据库   属性   指定   查询
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图