【问题标题】:Relational Algebra and Confusing one Complex Examples关系代数和混淆一个复杂的例子
【发布时间】:2015-05-10 14:39:46
【问题描述】:

我们有 3 个关系:

Students(sid, sname)
Courses(cid, cname, dept)
take(sid, cid, grade)

We want to find student numbers of students whose these students take all courses that present in 'CS' department

为什么(第 4 行)是这个查询的答案?

任何人都可以说从(第 1 行)到(第 3 行)不同。我在 DB 的 Solved-Ex 中读到了这个。

【问题讨论】:

    标签: sql database database-design relational-database relational-algebra


    【解决方案1】:

    第四行的另一种说法是:

    all students
    except
    (
        all combinations of students and CS courses
        except
        all taken courses
    )
    

    括号之间的集合包含所有未上过的学生 + CS 课程组合。从所有学生中减去这个,就得到了参加所有 CS 考试的学生。

    【讨论】:

    • 除了所有的考试吗?你什么意思?
    • PI sid,cid (take) 表示所有已参加的考试。 PI 只是丢弃等级。
    • 我认为只要参加就足够了,不要怀疑考试!我错了吗?
    • 嗯,是的,我用“考试”作为参加课程的同义词。
    • 请问(1)到(3)是什么意思?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-20
    • 2016-01-13
    • 2015-02-21
    相关资源
    最近更新 更多