CSc 8710 Deductive Databases and Logic Programming
Fall 1998
Programming Assignment #2
September 21, 1998 (Monday)

1.
Consider the following relations of the mailorder database.
EMPLOYEES(ENO,ENAME,ZIP,HDATE)
PARTS(PNO,PNAME,QOH,PRICE,LEVEL)
CUSTOMERS(CNO,CNAME,STREET,ZIP,PHONE)
ORDERS(ONO,CNO,ENO,RECEIVED,SHIPPED)
ODETAILS(ONO,PNO,QTY)
ZIPCODES(ZIP,CITY)
Write Prolog predicates that answer the following queries:
(a)
Get names of parts that cost less than 20.00.
(b)
Get the names and cities of employees who have taken orders for parts costing more than $50.
(c)
Get pairs of customer number values of customers who have the the same zipcode.

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

(e)
Get names of customers who have ordered parts ONLY from employees living in Wichita.

(f)
Get names of customers who have ordered ALL parts costing less than $20.

(g)
Get the numbers and names of employees who have never made a sale to a customer who live in the same zipcode as the employee.

2.
Consider the following relations of the gradebook database.
CATALOG(CNO,CTITLE)
STUDENTS(SID,FNAME,LNAME,MINIT)
COURSES(TERM,LINENO,CNO,A,B,C,D)
COMPONENTS(TERM,LINENO,COMPNAME,MAXPOINTS,WEIGHT)
ENROLLS(SID,TERM,LINENO)
SCORES(SID,TERM,LINENO,COMPNAME,POINTS)
Write Prolog predicates that answer the following queries:
(a)
Get the names of students enrolled in the Automata class in the f96 term.
(b)
Get the course numbers and titles of courses in which Timothy Thomas has enrolled.

(c)
Get the SID values of students who did not enroll in any class during the f96 term.

(d)
Get the SID values of students who have enrolled in csc226 and csc227.

(e)
Get the SID values of students who have enrolled in csc226 or csc227.

(f)
Get the SID values of students who have enrolled in all the courses in the catalog.

(g)
Get the names of students who have not enrolled in any course.



Dr. Raj Sunderraman
9/14/1998