列转换的关系代数规则 [英] Relational Algebra rule for column transformation

查看:60
本文介绍了列转换的关系代数规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关系代数中列转换的规则是什么?例如,我想将一列的所有值除以该列的平均值.我可以使用聚合规则获得平均值.但是找不到列操作的规则.P.S:我对规则很感兴趣(比如 \Pi 用于投影).

What is the rule for the transformation of a column in Relational Algebra? For example, I want to divide all values of a column with the average of that column. I can get average using aggregate rule. But cannot find the rule for column manipulation. P.S: I am interested in the rule (like \Pi is used for projection).

推荐答案

对此没有标准的方法.也没有单一的关系代数,所以你应该参考你的.

There's no standard approach to this. Also there's no single relational algebra, so you should give a reference to yours.

假设您以称为 DIVIDE 的常量基关系形式为列的值提供除法运算符,其中包含 dividend/divisor 元组>=.我将使用最简单的代数,标题是属性名称的集合.假设我们有输入关系 R 与列 c &平均A.我们想要像 R 这样的关系,但是每一列 c 的值都设置为其原始值除以 A.

Suppose you supply the division operator on values of a column in the form of a constant base relation called DIVIDE holding tuples where dividend/divisor=quotient. I'll use the simplest algebra, with headings that are sets of attribute names. Assume we have input relation R with column c & average A. We want the relation like R but with each column c value set to its original value divided by A.

这个版本从最简单的规范表达式开始机械地转换为代数:

This version starts from the simplest specification expression & mechanically converts to algebra:

/* rows where
EXISTS dividend [R(dividend) & DIVIDE(dividend, A, c)]
*/
PROJECT c (
        RENAME c\dividend (R)
    NATURAL JOIN
        RENAME quotient\c (
            PROJECT dividend, quotient (SELECT divisor=A (DIVIDE))))

这个版本有一个不太简洁的规范表达式,它是从更简洁的代数中机械派生出来的:

This version has a less concise specification expression mechanically derived from more concise algebra:

/* rows where
EXISTS quotient [
        quotient=c
    &   THERE EXISTS c, divisor [
            R(c) & DIVIDE(c, divisor, quotient) & divisor=A]]
*/
RENAME quotient\c (
    PROJECT quotient (
        R NATURAL JOIN RENAME dividend\c (SELECT divisor=A (DIVIDE))))

另请参阅关系代数 - 重新编码列值.

这篇关于列转换的关系代数规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆