-1

假设我有以下关系:

Academic(academicID (PK), forename, surname, room)
Contact (contactID (PK), forename, surname, phone, academicNO (FK))

我正在使用 Java,我想了解符号的使用。

Π( relation, attr1, ... attrn )表示将 n 个属性投影到关系之外。
σ( relation, condition)表示选择符合条件的行。
⊗(relation1,attr1,relation2,attr2)表示在命名属性上连接两个关系。
relation1 – relation2是两种关系的区别。
relation1 ÷ relation2将一种关系除以另一种关系。

我见过的例子使用了三个表。我想知道当只涉及两个表(学术和联系)而不是三个(学术、联系、拥有)时的逻辑。

我正在使用这种结构:

LessNumVac = Π( σ( job, vacancies < 2 ), type )
AllTypes = Π( job, type )
AllTypes – LessNumVac

我如何构建代数:

列出学术“约翰”拥有的所有联系人的姓名

4

2 回答 2

0
于 2013-03-11T22:00:39.250 回答
0

List the names of all contacts who is owned by academic "John".

For that, you would join the Academic and Conctact relations, filter for John, and project the name attributes. For efficiency, select John before joining:

πforename, surename (Contact ⋈<sub>academicNO = academicID (πacademicIDforename = "John" Academic))))

于 2013-03-12T13:40:35.807 回答