本文介绍了关系代数和关系微积分的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关系代数和关系演算之间的确切区别是什么.最多的参考就是

What is the exact difference between relational algebra and relational calculus. At most of the reference, it will be

关系代数是过程性的,微积分是非过程性的.

那么,这些代表什么.但是,我们可以使用关系解决所有问题代数.那么为什么我们会使用关系演算.除了定义,非常感谢示例的解释.

So, what is these stands for. However, we can solve all the problems using relationalalgebra. Then why we would use relational calculus. Except definition, Explanation with example is much appreciated.

推荐答案

TL;DR: 查询调用 RA(关系代数)运算符 &查询两个关系演算(RC)TRC(元组RC)&DRC(域 RC)是同一事物的不同语法:关系值或关系值的元组必须满足的属性/条件.与 SQL 一样(它们的混合(up)).与谓词微积分一样,数学、逻辑、科学(包括计算机科学)中的精确语言工程(包括软件工程).RA 作为程序与 RC 作为声明性是一个神话.

TL;DR: Queries calling RA (relational algebra) operators & queries of the two relational calculi (RCs) TRC (tuple RC) & DRC (domain RC) are different syntax for the same thing: a relation value or the property/condition that a relation value's tuples have to meet. As is SQL (a mix(up) of them). As is the predicate calculus, the language of precision in mathematics, logic, science (including computer science) & engineering (including software engineering). And RA as procedural vs RCs as declarative is a myth.

一个关系保存了使某些谓词--由属性参数化的语句模板成为真正的命题--语句的元组.

A relation holds the tuples that make some predicate--statement template parameterized by attributes--into a true proposition--statement.

/* tuples where employee PERSONNAME lives on STREET in CITY */
Employee
/* tuples where employee PERSONNAME works at COMPANY for $SALARY */
WorksFor

RA 风格的查询表达式涉及属性名称、关系变量/常量名称、关系字面量(涉及属性名称和值)&关系运算符.运算符是 JOIN、UNION、MINUS、PROJECT、RESTRICT 等.它表示您通过评估表达式获得的关系值.但这也是满足价值的要求.

A RA-style query expression involves attribute names, relation variable/constant names, relation literals (involving attribute names & values) & relation operators. The operators are JOIN, UNION, MINUS, PROJECT, RESTRICT, etc. It denotes the relation value that you get by evaluating the expression. But it is also requirements for the value to meet.

/* RA query for tuples where
    FOR SOME STREET & CITY [employee PERSONNAME lives on STREET in CITY]
AND NOT FOR SOME COMPANY & SALARY
        [employee PERSONNAME works at COMPANY for $SALARY AND COMPANY = 'FBC']
*/
    PROJECT PERSONNAME (Employee)
MINUS PROJECT PERSONNAME (RESTRICT COMPANY = 'FBC' (WorksFor))

RC 表达式是关系值的set-builder 符号.它涉及带有关系变量/常量名称、属性名称和谓词的谓词.值,谓词运算符 &量化名称(逻辑变量).运算符是 AND、OR、NOT、FOR SOME/ALL 和 =.它通常被视为满足价值的要求.但它也表示您通过评估表达式或某个等价的表达式获得的关系值.

A RC expression is set-builder notation for a relation value. It involves a predicate with relation variable/constant names, attribute names & values, predicate operators & quantified names (logic variables). The operators are AND, OR, NOT, FOR SOME/ALL and =. It is usually seen as requirements for the value to meet. But it also denotes the relation value that you get by evaluating the expression or a certain equivalent one.

DRC 具有作为属性的量化名称.我们对每个属性有一个参数的语句使用简写:

The DRC has quantified names that are attributes. We use a shorthand for statements with one parameter per attribute:

Employee(PERSONNAME, STREET, CITY)
    means (PERSONNAME, STREET, CITY) IN Employee
    means employee PERSONNAME lives on STREET in CITY
WorksFor(PERSONNAME, COMPANY, SALARY)
    means (PERSONNAME, COMPANY, SALARY) IN WorksFor
    means employee PERSONNAME works at COMPANY for $SALARY

/* DRC query for the same tuples as the RA query above */
tuples like (PERSONNAME) where
    FOR SOME STREET & CITY [Employee(PERSONNAME, STREET, CITY)]
AND NOT FOR SOME COMPANY & SALARY
        [WorksFor(PERSONNAME, COMPANY, SALARY) AND COMPANY = 'FBC']

TRC 有量化的元组名称.我们点一个名称来获取与其中的属性名称相关联的值.(就像编程语言记录的一个字段.)我们使用带有一个参数(元组)的语句的简写:

The TRC has quantified names that are tuples. We dot a name to get the value associated with an attribute name in it. (Like for a field of a programming language record.) We use a shorthand for statements with one parameter (a tuple):

Employee(T)
    means T IN Employee
    means employee T.PERSONNAME lives on T.STREET in T.CITY
Worksfor(T)
    means T IN Worksfor
    means employee T.PERSONNAME works at T.COMPANY for $T.SALARY

/* TRC query for the same tuples as the RA query above */
tuples equal to some tuple T like (PERSONNAME) where
    FOR SOME E [Employee(E) AND E.PERSONNAME = T.PERSONNAME]
AND NOT FOR SOME W [
        WorksFor(W)
    AND W.COMPANY = 'FBC'
    AND E.PERSONNAME = T.PERSONNAME
    ]

(教授了 RA 和 RC 原始版本的一些变体.例如,一些按顺序识别参数,而另一些按名称识别.有时会添加额外的功能.例如,允许在 RC 中调用函数与允许某些功能一样具有表现力关系常量加运算符 R RENAME A TO N 在 RA 中.)

(A few variants on the originals of the RA and RCs are taught. Eg some identify arguments by order and others by name. Sometimes extra capabilities are added. Eg allowing a function call in a RC is as expressive as allowing a certain relation constant plus operator R RENAME A TO N in a RA.)

然而,RA算子和RC算子之间存在对应关系&RA 表达式和 RC 表达式之间:

However, there is a correspondence between RA operators and RC operators & between RA expressions and RC expressions:

如果:
• R -- 保存元组,其中 R(...)
• S -- 保存元组,其中 S(...)
然后:
• R JOIN S 保存元组,其中 R(...) AND S(...)
• R UNION S 保存元组,其中 R(...) OR S(...)
• R MINUS S 保存元组,其中 R(...) AND NOT S(...)
• R PROJECT 要保留的列 包含要删除的的元组,R(...)
• R RESTRICT condition 保存元组,其中 R(...) AND condition

If:
• R -- holds tuples where R(...)
• S -- holds tuples where S(...)
then:
• R JOIN S holds tuples where R(...) AND S(...)
• R UNION S holds tuples where R(...) OR S(...)
• R MINUS S holds tuples where R(...) AND NOT S(...)
• R PROJECT columns to keep holds tuples where FOR SOME columns to drop, R(...)
• R RESTRICT condition holds tuples where R(...) AND condition

RA 表达式的值是满足相应 RC 表达式的元组.

如果我们想逐个操作符地从 RC 表达式映射到 RA 表达式,那么我们需要扩展的 RA 操作符:一个泛化 UNION &一个对应于 NOT.这些不是我们希望在实现中实际使用的运算符——返回的关系值在某种意义上过大.但是每个使用它们的 RC 表达式都可以机械地重新排列为仅使用基本 RA 运算符的标准形式.

If we want to map from a RC expression to an RA expression on an operator-by-operator basis then we need extended RA operators: one generalizing UNION & one corresponding to NOT. Those aren't operators we would like to actually use in an implementation--the relations values returned are in a certain sense undesirably big. But every RC expression using them can be rearranged mechanically to a normal form that uses only basic RA operators.

所以:RA 作为程序与 RC 作为声明性是一个神话.每个 RA 算子都有一个对应的 RC 算子,每个 RC 算子都有一个(可能扩展的)对应的 RA 算子,一个的每个表达式都有(在基本和扩展意义上)另一个的相应表达式.它们是相同事物的两种表示法.任何一个的表达式都可以通过将其作为解析或规范化来执行而被视为程序性",并通过以其他方式执行而被视为声明性".神话试图捕捉这样一个想法,即 RC 表达式不像使用基本 RA 运算符的表达式那样逐个运算符.但是 RC 表达式确实使用基本运算符识别其非显而易见范式的 RA 表达式.它逐个操作符,就像一个包含扩展操作符的 RA 表达式.

So: RA as procedural vs RCs as declarative is a myth. Every RA operator has a corresponding RC operator, every RC operator has a (possibly extended) corresponding RA operator, and every expression of one has (in basic and extended senses) a corresponding expression of the other. They are two notations for the same things. An expression of either can be taken as "procedural" by executing it as parsed or normalized and as "declarative" by executing it otherwise. The myth is trying to capture the idea that a RC expression isn't operator-by-operator like an expression using basic RA operators. But a RC expression does identify its non-obvious normal form's RA expression using basic operators. And it is operator-by-operator like a RA expression including extended operators.

(由于的历史,这个神话可能有所帮助.现代代数"的表达式带有运算符取值并可以计算.微积分"又名分析--微分和积分--具有通过无法计算的无限极限和求和来描述值的表达式.我们以其他方式计算,通常只计算近似值.)

(The myth may be helped because of the history of the words. "Modern algebra" has expressions with operators taking & giving values and can be calculated. "The calculus" aka analysis--differentiation & integration--has expressions describing values via impossible-to-calculate infinite limits & summations. We calculate in other ways, in general only calculating approximations.)

(另外,具有讽刺意味的是:谓词演算"被认为是声明性地"指定事物,而不考虑如何以其他方式计算或估计它们.但是这种表达式的标准语义/含义是通过遵循以下算法给出的遍历表达式树.所以它有一个明显的程序"解释.)

(Also, ironically: "The predicate calculus" is considered to specify things "declaratively" without regard to how they may be otherwise calculated or estimated. But the standard semantics/meaning of such an expression is given by following an algorithm that walks the expression tree. So it has an obvious "procedural" interpretation.)

这篇关于关系代数和关系微积分的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 06:11