数据库理论4

6.11 考虑图6-22所示关系数据库,主码加了下划线。给出关系代数表达式来表示下列的每一个查询:

employee(person_name,street,city)
works(person_name,company_name,salary)
company(company_name,city)
manages(person_name,manager_name)
  1. 找出 First Bank Corporation的所有员工姓名。

    1
    2
    3
    select person_name 
    from works
    where company_name = 'First Bank Corporation';
  2. 找出 First Bank Corporation所有员工的姓名和居住城市。

    1
    2
    3
    4
    select e.person_name, e.city
    from works w, employee e
    where e.person_name = w.person_name
    and w.company_name = 'First Bank Corporation';
  3. 找出 First Bank Corporation所有年收入在10000美元以上的员工姓名和居住的街道、城市。

    1
    2
    3
    select e.person_name, e.street, e.city
    from works w, employee e
    where e.person_name = w.person_name and w.salary > 10000 and w.company_name = 'First Bank Corporation';
  4. 找出所有居住地与工作的城市在同一个城市的员工姓名。

    1
    2
    3
    select e.person_name
    from works w, employee e
    where e.person_name = w.person_name and e.city = w.city;
  5. 假设公司可以位于几个城市之中。找出满足下面条件的所有公司,它位于Small Bank Corporation所位于的每一个城市。

    1
    2
    3
    select A.company_name
    from company A , company B
    where B.company_name = 'Small Bank Corporation' and A.city = B.city;