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.
Consider the following relations of the investment portfolio database.
MEMBER(MID,password,fname,lname,address,email,cash_balance)
SECURITY(SYMBOL,cname,current_price,ask_price,bid_price)
TRANSACTION(MID,SYMBOL,TRANS_DATE,trans_type,quantity,
price_per_share,commission,amount)
Write Prolog predicates that answer the following queries:
- (a)
- Get company names of securities whose current
price is greater than $100.00.
- (b)
- Get names of members who have purchased ORCL shares.
- (c)
- Get names of members who have purchased ORCL
shares but NOT SYBS shares.
- (d)
- Get names of members who purchase ONLY ORCL shares.
- (e)
- Get company names of securities whose shares are
purchased by ALL members.
- (f)
- Get the names of members who have purchased shares from ALL of the
companies that member with MID=11000 has purchased shares from.
- (g)
- Get the names of members who have purchased shares ONLY from
a subset of the companies that member with MID=11000 has purchased shares from.
- (g)
- Get the names of members who have purchased shares from
EXACTLY the same companies that member with MID=11000 has purchased shares from.