6.34
(a) List the names of all employees in department 5 who work more
    than 10 hours per week on the ProductX project.

answer(F,L) :-
  employee(F,_,L,S,_,_,_,_,_,5),
  projects('ProductX',P,_,_),
  works_on(S,P,H), H > 10.0.$

6.34
(b) List the names of employees who have a dependent with the same
    first name as themselves.

answer(F,L) :-
  employee(F,_,L,S,_,_,_,_,_,_),
  dependent(S,F,_,_,_).$

6.34
(c) List the names of employees who are directly supervised by Franklin
    Wong.

answer(F,L) :-
  employee(F,_,L,_,_,_,_,_,S,_),
  employee('Franklin',_,'Wong',S,_,_,_,_,_,_).$

6.34
(d) List the names of employees who work on every project.

temp1(S,P) :- 
  employee(_,_,_,S,_,_,_,_,_,_), projects(_,P,_,_).
temp2(S,P) :-
  works_on(S,P,_). 
temp3(S) :-
  temp1(S,P), not temp2(S,P).
answer(F,L) :-
  employee(F,_,L,S,_,_,_,_,_,_),
  not temp3(S).$

6.34
(e) List the names of employees who do not work on any project.

temp(S) :-
  works_on(S,_,_). 
answer(F,L) :-
  employee(F,_,L,S,_,_,_,_,_,_),
  not temp(S).$

6.34
(f) List the names and addresses of employees who work on at least
    one project located in Houston but whose department has no location
    in Houston.

allDepts(D) :-
  department(_,D,_,_). 
deptsWithHoustonLoc(D) :-
  dept_locations(D,'Houston').
deptsWithNoHoustonLoc(D) :-
  allDepts(D), 
  not deptsWithHoustonLoc(D).
temp1(S) :-
  employee(_,_,_,S,_,_,_,_,_,D),
  deptsWithNoHoustonLoc(D).
temp2(S) :-
  projects(_,P,'Houston',_),
  works_on(S,P,_).
answer(F,L,A) :-
  employee(F,_,L,S,_,A,_,_,_,_),
  temp1(S), temp2(S).$

6.34
(g) List the names of department managers who have no dependents.

allMgrs(S) :-
  department(_,_,S,_). 
managersWithDependents(S) :-
  dependent(S,_,_,_,_). 
answer(F,L) :-
  employee(F,_,L,S,_,_,_,_,_,_),
  allMgrs(S), not managersWithDependents(S).$

----------------------------------------------------------------------
6.35
(a) Retrieve the names of parts that cost less than $20.00

answer(N) :-
  parts(_,N,_,C,_), C < 20.0.$

6.35
(b) Retrieve the names and cities of employees who have taken orders
    for parts costing more than $20.00.

answer(N,T) :-
  parts(P,_,_,C,_), C > 20.0,
  odetails(O,P,_),
  orders(O,_,E,_,_),
  employees(E,N,Z,_),
  zipcodes(Z,T).$

6.35
(c) Retrieve the pairs of customer number values of customers who live
    in the same Zip Code.

answer(C1,C2) :-
  customers(C1,_,_,Z,_),
  customers(C2,_,_,Z,_),
  C1 < C2.$

6.35
(d) Retrieve the names of customers who have ordered parts from employees
    living in Wichita.

answer(N) :-
  customers(C,N,_,_,_),
  orders(_,C,E,_,_),
  employees(E,_,Z,_),
  zipcodes(Z,'Wichita').$

6.35
(e) Retrieve the names of customers who have ordered ALL parts costing less
    than $20.00. (Note ALL in this query - different from problem in book).

temp1(C,P) :-
  customers(C,_,_,_,_),
  parts(P,_,_,R,_),
  R < 20.0.
temp2(C,P) :-
  orders(O,C,_,_,_),
  odetails(O,P,_).
temp(C) :-
  temp1(C,P),
  not temp2(C,P).
answer(N) :-
  customers(C,N,_,_,_),
  not temp(C).$

6.35
(f) Retrieve the names of customers who have not placed an order.

temp(C) :-
  orders(_,C,_,_,_).
answer(N) :-
  customers(C,N,_,_,_),
  not temp(C).$

6.35
(g) Retrieve the names of customers who have placed exactly two orders.

twoOrMore(C) :-
  orders(O1,C,_,_,_),
  orders(O2,C,_,_,_),
  O1 <> O2.
threeOrMore(C) :-
  orders(O1,C,_,_,_),
  orders(O2,C,_,_,_),
  orders(O3,C,_,_,_),
  O1 <> O2,
  O2 <> O3,
  O1 <> O3.
answer(N) :-
  customers(C,N,_,_,_),
  twoOrMore(C),
  not threeOrMore(C).$
---------------------------------------------------------------------------