/* ------------------------------------------------------------------------ */ /* Do not edit this part ---------------------------------------------------*/ /* ------------------------------------------------------------------------ */ :- consult('emp.pl'). :- consult('subtotal.pl'). :- consult('query.pl'). %Database emp: %emp(Empno, Ename, Job, Mgr, Hiredate, Sal, Comm, Deptno) %dept(Deptno, Dname, Loc) %salgrade(Grade, Losal, Hisal) /* ------------------------------------------------------------------------ */ /* Example -----------------------------------------------------------------*/ /* ------------------------------------------------------------------------ */ /* Print all jobs. */ job(J) :- emp(_, _, J, _, _, _, _, _). /* To run this query, use (in another window, after saving this file): 'pl -s queries_emp.pl' and then (Prolog prompt): make. ?- q(job(J)). */ /* ------------------------------------------------------------------------ */ /* Write and test the following queries ----------------------------------- */ /* ------------------------------------------------------------------------ */ /* Print names and jobs of employees with salary at least 2000. */ /* Print names and jobs of employees who work in department 30. */ /* Print the number of department in which the president works. */ /* Print names of employees who were hired between 1 September 1981 and 31 October 1981. */ /* Print names and salaries of managers, sort the output in the descending order of salaries. */ /* Print names, brutto incomes, national insurance contributions, income taxes and netto incomes of employees (subtract 13.4% for national insurance and 19% for income tax). */ /* Print names and the number of working years (since hired) of all employees. */ /* Print names of all employees with the first letters of their department names. */ /* Print name and "total salary" (total salary = salary + comm) of each employee. (Warning: the column comm may contain NULL values.) */ /* Print jobs of employees who work in Chicago. */ /* Print tuples [Name, City, Coworker] which stand for all employees, their working places and names of their co-workers (employees who work in the same department). */ /* Print names, department names and salaries of all employees whose salaries are greater than the lowest salary in department 20. */ /* Print names of employees together with names of their managers. */ /* Which departments contain all job positions? */ /* Which departments are empty (have no employees)? */ /* Which employees manage only clerks? */ /* Which departments employ no salesmen? */ /* Find names of all employees who are subsidiaries of Blake - both direct and indirect subsidiaries. (This query is a tricky one, skip it unless you understand what precisely you are doing.) */