Find all projects supplied by at least one supplier

Assignment Help Computer Engineering
Reference no: EM132210545

Question

Write a program in Prolog with the set of facts:

supp(s1,'Smith',20,'London').

supp(s2,'Jones',10,'Paris').

supp(s3,'Blake',30,'Paris').

supp(s4,'Clark',20,'London').

supp(s5,'Adams',30,'Athens').

part(p1, 'Nut', 'Red', 12, 'London').

part(p2, 'Bolt', 'Green', 17, 'Paris').

part(p3, 'Screw', 'Blue', 17, 'Oslo').

part(p4, 'Screw', 'Red', 14, 'London').

part(p5, 'Cam', 'Blue', 12, 'Paris').

part(p6, 'Cog', 'Red', 19, 'London').

proj(j1, 'Sorter', 'Paris').

proj(j2, 'Display', 'Rome').

proj(j3, 'OCR', 'Athens').

proj(j4, 'Console', 'Athens').

proj(j5, 'RAID', 'London').

proj(j6, 'EDS', 'Oslo').

proj(j7, 'Tape', 'London').

sppj(s1, p1, j1, 200).

sppj(s1, p1, j4, 700).

sppj(s2, p2, j1, 400).

sppj(s2, p2, j2, 200).

sppj(s2, p2, j3, 200).

sppj(s2, p2, j4, 500).

sppj(s2, p2, j5, 600).

sppj(s2, p2, j6, 400).

sppj(s2, p2, j7, 800).

sppj(s2, p5, j2, 100).

sppj(s3, p2, j1, 200).

sppj(s3, p4, j2, 500).

sppj(s4, p6, j3, 300).

sppj(s4, p6, j7, 300).

sppj(s5, p2, j2, 200).

sppj(s5, p2, j4, 100).

sppj(s5, p5, j5, 500).

sppj(s5, p5, j7, 100).

sppj(s5, p6, j2, 200).

sppj(s5, p1, j4, 100).

sppj(s5, p2, j4, 200).

sppj(s5, p4, j4, 800).

sppj(s5, p5, j4, 400).

sppj(s5, p6, j4, 500).

Requirements:

Given the database of tables (i.e., lists in Scheme and facts in Prolog), you must now write queries (i.e., functions in Scheme and rules in Prolog) for each of the following:

When given a pair of projects, find all suppliers who supply both projects. Return the entire entry (i.e., S#, Sname, Status, City) for the supplier.

When given a city, find all parts supplied to any project in that city. Once again, return the entire entry for the part. Find all parts supplied to any project by a supplier in the same city. In this case, results are organized by all parts for every city in the database.

Find all projects supplied by at least one supplier not in the same city.

Find all suppliers that supply at least one part supplied by at least one supplier who supplies at least one red part.

Find all pairs of city values such that a supplier in the first city supplies a project in the second city.

Find all triples of city, part#, city, such that a supplier in the first city supplies the specified part to a project in the second city, and the two city values are different.

When given a supplier, find all projects supplied entirely by that supplier.

One possible approach to the problem would be to write functions (rules) that perform the basic operations of selection (finding appropriate rows of tables), projections (printing out an entire row of a table), and join (merging two tables on a column-basis, similar to a Cartesian product).

These three basic operations can then be combined to answer the queries posed above. A second approach would be to write functions (rules) specifically to answer each of the queries.

Reference no: EM132210545

Questions Cloud

What factors contribute to ethical differences : List four ethical leadership behaviors described in your reading. What factors contribute to ethical differences?
Advertisements that offer male consumers products : Advertisements that offer male consumers products that will enhance their personal appearance and sexual performance are subject to the criticism that marketing
Prompt the user for an eight digit integer and then prints : Write a program that prompts the user for an eight digit integer and then prints a long formatted date.
Produce the probability mass function of the bernouilli : Write a program to produce the probability mass function of the Bernouilli distribution, i.e. a function that only returns 2 possible values(0 and 1).
Find all projects supplied by at least one supplier : Find all suppliers that supply at least one part supplied by at least one supplier who supplies at least one red part.
Write a little man program that prints out the sums of odd : Write a Little Man program that prints out the sums of the odd values from 1 to 39. The output will consist of 1, 1+3, 1+3+5, 1+3+5+7... No input is required.
How much cash after taxes would sandra receive : How much cash after taxes would Sandra receive from her investment in the first year if BAL is organized as either an LLC or a C corporation
Display the total net gross amounts and their averages : The program output should show each employee's name, gross pay, and net pay, and should also display the total net gross amounts and their averages.
Produce a table of decimal numbers and roman numerals : Write a program to produce a table of decimal numbers and roman numerals from 1 to 1000.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Research the recording industry association of america

Research the Recording Industry Association of America (RIAA) and the Motion Picture Association of America (MPA).

  How would you incorporate diversity in designing a team

Think about how to build teams in terms of designing the task, selecting the people, and then, managing their relationships.

  Assessing the importance of project management soft skills

Assessing the importance of project management soft skills in the context of project success rate. The response must be typed.

  How would you respond if the user told you he thought models

How would you respond if the user told you he thought models were a waste of time and that you should begin coding?

  Calculating relative value points and monetary value points

Draw a diagram to highlight the product road map and product life cycle through the use of graphical tools in Visio, or an open source alternative such as Dia.

  What is the value of j after the last statement

Lunix program (Short circuit evaluation) Consider the source code. What is the value of j after the last statement above?

  Define use of service-oriented architecture and why

Giving reasons for your answer, suggest two types of applications where you would not recommend the use of service-oriented architecture and why.

  Write an analysis of four papers on topic in Robotics

SIT740 Research and Development in Information Technology Assignments. Write an analysis of four papers on a given topic in AI & Robotics

  Explain the concept of unified change management

Describe the concept of "change request" in your own words. List down the activities performed by "Software Review Board" in the change request process.

  Write a program that asks the user about his name

Write a program that asks the user about his/her name (you need to take the first name and family name as ONE string).

  Suppose that you are working for the marketing department

q1. assume that you are on the staff of a prc legislator. outline the arguments that you would use to support a law

  Prompt the user to input an integer from the input device

Write a program to prompt the user to input an integer from the input device. Print out the fractional of the integer.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd