9.4 Domain Relational Calculus: Query Language for Relational Databases

Query Examples: (These are the queries from problem 7.18 of the
  El-Masri/Navathe text).

(1) Get names of all employees in department 5 who work more than 10
    hours/week on the ProductX project.

    { x,y,z | (Exists s,a,b,c,d,e) (employee(x,y,z,s,a,b,c,d,e,5) and 
                  (Exists p,h)(works_on(s,p,h) and 
                     (Exists o,q)(project('ProductX',p,o,q) and h >= 10 )))}
                             
(2) Get names of all employees who have a dependent with the same first
    name as themselves.

    { x,y,z | (Exists s,a,b,c,d,e,f) (employee(x,y,z,s,a,b,c,d,e,f) and 
                   (Exists g,h,i)(dependent(s,x,g,h,i))) }

(3) Get the names of all employees who are directly supervised by
    Franklin Wong.

    { x,y,z | (Exists a,b,c,d,e,s,f) (employee(x,y,z,a,b,c,d,e,s,f) and 
                (Exists m,n,p,q,r,t)(
                   employee('Franklin',m,'Wong',s,n,o,p,q,r,t))) }

(4) Get the names of all employees who work on every project.

    { x,y,z | (Exists s,a,b,c,d,e,f) (employee(x,y,z,s,a,b,c,d,e,f) and 
                  (Forall n,p,q,r) (project(n,p,q,r) -> 
                                      (Exists h)(works_on(s,p,h)))) }

(5) Get the names of employees who do not work on any project.

    { x,y,z | (Exists s,a,b,c,d,e,f) (employee(x,y,z,s,a,b,c,d,e,f) and 
                     not (Exists p,h)(works_on(s,p,h))) }

(6) Get the names and addresses of employees who work for at least one
    project located in Houston but whose department does not have a 
    location in Houston.

    { x,y,z | (Exists s,a,b,c,d,e,f) (
                   employee(x,y,z,s,a,b,c,d,e,f) and 
                   (Exists p,h,n,q) (works_on(s,p,h) and 
                                     project(n,p,'Houston',q)) and
                   not dept_locations(f,'Houston') ) } 
          
(7) Get the names and addresses of employees who work for at least one
    project located in Houston or whose department does not have a 
    location in Houston. (Note: this is a slight variation of the
    previous query with 'but' replaced by 'or').

    { x,y,z | (Exists s,a,b,c,d,e,f) (
                   employee(x,y,z,s,a,b,c,d,e,f) and 
                   ((Exists p,h,n,q) (works_on(s,p,h) and 
                                     project(n,p,'Houston',q)) or
                   not dept_locations(f,'Houston') ) ) } 
          
(8) Get the last names of all department managers who have no dependents.

    { z | (Exists x,y,s,a,b,c,d,e,f) (employee(x,y,z,s,a,b,c,d,e,f) and 
              (Exists m,n,q)(department(m,n,s,q) and 
                   not (Exists h,i,j,k)(dependent(s,h,i,j,k)))) }