资源描述:
《《数据库原理习题课》PPT课件》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、主讲:王新颖E-mail:xinying@jlu.edu.cn吉林大学软件学院1、基本的关系代数运算2、附加的关系代数运算3、扩展的关系代数运算4、数据库修改Copyright:XinyingWangemployee(person-name,street,city)works(person-name,company-name,salary)company(company-name,city)manages(person-name,manager-name)Copyright:XinyingWang找出FirstBan
2、kCorporation的所有员工的姓名Πperson-name(company-name=“FirstBankCorporation”(works))找出FirstBankCorporation的所有员工的姓名和居住城市Πperson-name,city(company-name=“FirstBankCorporation”(employeeworks))找出FirstBankCorporation的所有年收入在10,000美元一时的员工的姓名和居住的街道、城市Πperson-name,street,city(
3、salary>10000(company-name=“FirstBankCorporation”(employeeworks)))找出所有居住地与工作的公司在同一城市的员工姓名Πperson-name(employeeworkscompany)Copyright:XinyingWang找出与其经理居住在同一城市同一街道的所有员工的姓名Πperson-name(manager-name=employee2.person-name∧manages.person-name=employee.person-name∧e
4、mployee.street=employee2.street∧employee.city=employee2.city(employee×(manages×(ρemployee2(employee)))))6.找出比SmallBankCorporation所有员工收入都高的所有的员工的姓名Πperson-name(works)−(Πworks.person-name(works.salary≤works2.salary∧works2.company-name=“SmallBankCorporation”(work
5、s×(ρworks2(works))))Copyright:XinyingWang7.找出数据库中不在FirstBankCorporation工作的所有员工的姓名每个人只能在一个公司工作(不允许兼职)Πperson-name(company-name≠“FirstBankCorporation”(works))每个人可以在不只一个公司工作(允许兼职)Πperson-name(employee)−Πperson-name(σcompany-name=“FirstBankCorporation”(works))Copy
6、right:XinyingWang8.修改数据库,使Jones现在居住在NewTownemployee←employee-person-name=“Jones”(employee)employee←employee∪{(“Jones”,null,“Newtown”)}9.为工资不高于100,000的经理提高工资10%,高于100,000的提高工资3%t1←Πperson-name,company-name,salary(person-name=manager-name(employee×works))t2←Πpe
7、rson-name,company-name,salary*1.1(salary≤100000(t1))t3←Πperson-name,company-name,salary*1.03(salary>100000(t1))works←(works-t1)∪t2∪t3Copyright:XinyingWang10.删除works关系中SmallBankCorporation的员工的所有元组t1←Πperson-name,company-name,salary(company-name=“SmallBankCorp
8、oration”(works))works←(works-t1)11.找出员工最多的公司r1←company-namegcount(person-name)asperson-number(works)r2←gmax(person-number)(r1)Πcompany-name(person-number=r2(r1))Copyright:X