关系代数
关系代数
关系S1 |
Sno | Sname | Sdept |
No0001 | Mary | IS |
No0003 | Candy | IS |
No0004 | Jam | IS |
关系S2 |
Sno | Sname | Sdept |
No0001 | Mary | IS |
No0008 | Katter | IS |
No0021 | Tom | IS |
并
合并所有
S1∪S2 |
Sno | Sname | Sdept |
No0001 | Mary | IS |
No0003 | Candy | IS |
No0004 | Jam | IS |
No0008 | Katter | IS |
No0021 | Tom | IS |
交
只留下两者都有的
S1∩S2 |
Sno | Sname | Sdept |
No0001 | Mary | IS |
差
前者里删除后者有的(注意有先后顺序)
S1-S2 |
Sno | Sname | Sdept |
No0001 | Mary | IS |
No0003 | Candy | IS |
No0004 | Jam | IS |
笛卡尔积
两者相乘(每项都与另外的每一个结合)
S1×S2 |
Sno |
Sname |
Sdept |
Sno |
Sname |
Sdept |
No0001 |
Mary |
IS |
No0001 |
Mary |
IS |
No0001 |
Mary |
IS |
No0008 |
Katter |
IS |
No0001 |
Mary |
IS |
No0021 |
Tom |
IS |
No0003 |
Candy |
IS |
No0001 |
Mary |
IS |
No0003 |
Candy |
IS |
No0008 |
Katter |
IS |
No0003 |
Candy |
IS |
No0021 |
Tom |
IS |
No0004 |
Jam |
IS |
No0001 |
Mary |
IS |
No0004 |
Jam |
IS |
No0008 |
Katter |
IS |
No0004 |
Jam |
IS |
No0021 |
Tom |
IS |
投影
选择列
πSno,Sname(S1) |
Sno |
Sname |
No0001 |
Mary |
No0003 |
Candy |
No0004 |
Jam |
选择
选择行
δSno=No0003(S1) |
Sno |
Sname |
Sdept |
No0003 |
Candy |
IS |
自然连接
关系S1 |
Sno | Sname | Sdept |
No0001 | Mary | IS |
No0003 | Candy | IS |
No0004 | Jam | IS |
关系S2 |
Sno | Age |
No0001 | 23 |
No0008 | 21 |
No0021 | 22 |
S1⋈S2 |
Sno |
Sname |
Sdept |
Age |
No0001 |
Mary |
IS |
23 |
软件设计师考试常考用其他方式实现自然连接