CS 377 - Database Systems
SQL Project 2 (2018)

Due: see class web page




If you have not read this yet for SQL project 1, you should read it now:

You must read the information/description on the SPJ project database in the URL below to do the project.

Specifically: pay attention to what the meaning of each relation is.



How to do SQL projects:









1. Assignment





2. SQL Queries Files that you need to turn in




3. SQL Queries

Important notes:

Express the following queries in SQL:

  1. Get name of suppliers who have at least 3 shipments to the project 'j4' and the number of shipments the supplier is shipping to project 'j4'

    Sample output:

    Answer: click here

  2. Find sname of suppliers who ships to every city where there is a project taking place.

    Suppose the cities where projects take place are: { London, Paris, Athens}, then the supplier must have a shipment to all these cities.

    Sample output:

    Answer: click here

  3. Get project number of projects that have shipments for all the parts with the highest weight

    Suppose the parts with the hightest weight are {p6, p8}, then the project must have shipments for both parts p6 and p8.

    Sample output:

    Answer: click here

  4. Find number of parts that have the second highest weight of all parts

    Sample output:

    Answer: click here

  5. For each supplier, show his supplier number and the project number of the projects that receive the highest number of shipments from this supplier and the number of shipments to these projects.

    Suppose s1 has 3 shipments to j1, 5 shipments to j2 and 5 shipments to j3, you must print s1, j2, 5 and s1, j3, 5. Do this for every supplier in the SPJ database.

    Sample output:

    Answer: click here

  6. Find sname of suppliers who have >= 2 shipments to all projects in the city that they live in.

    Suppose supplier s1 lives in Atlanta and projects j1 and j2 are in Atlanta. Supplier s1 is output by the query if and only if s1 has >= 2 shipments to project j1 and >= 2 shipments to project j2.

    Sample output:

    Answer: click here

  7. Find jnum of projects that have shipments with the highest total number of 'Screw' parts and show the number of 'Screw' parts being shipped to these projects.

    Suppose parts p1 and p2 are 'Screw' parts and suppose the spj relation contains the following shipments of 'Screw' parts:

    Then the output of this query is (j1, 400) and (j3, 400)

    Sample output:

    Answer: click here

  8. Find sname of suppliers who ship the part p3 to every projects in the city that the supplier lives.

    Suppose supplier s1 lives in Atlanta and projects j1 and j2 are in Atlanta. The s1 must have shipments of part p3 to j1 and j2.

    Sample output:


    Answer: click here

  9. Find the jnum of projects that have 5 or more shipments from suppliers that live in a different city than the project city (= "remote suppliers")

    Suppose project j1 is in Atlanta and has 7 shipments from suppliers who are not living in Atlanta, then j1 qualifies.

    Sample output:


    Answer: click here

  10. Get jnum for projects that has more shipments from "local suppliers" (= suppliers that live in the city where the project takes place) than "remote suppliers" (= non-local suppliers)

    Suppose project j1 takes places in Atlanta; j1 has 4 shipments from suppliers are in Atlanta and j1 has 3 shipments from suppliers that are not in Atlanta; then project j1 qualifies.

    Sample output:


    Answer: click here



Turn in





Extension request





Statement of Policy on Computer Assignments

Students will be graded partially on the basis of their programming assignments. These programming assignments are to be treated as examinations, and are expected to be your individual work. While discussions with other students in the course may be permitted or encouraged by your instructor, you should write your program yourself. The mathlab representatives are available to explain error messages, discuss briefly technical details with which you may not be familiar, and give short suggestions as to how you might detect logic errors. The reps should not, however be asked to write part or all of your program. Your instructor (and any teaching assistants assigned to the course) will be glad to help you to the extent that he or she feels reasonable.

Submissions based on other students solutions in prior offerings of the course specifically violate these guidelines, as do submissions prepared with the help of an outside "tutor".

You should take precautions to protect the confidentiality of your work: preserve the secrecy of your password, do not make files or directories sharable, pick up your printouts promptly and dispose of printouts where they will not tempt other students. All work should be done either in the class directory of your ITD account (preferred) or in your "priv" directory (only if you do not have a class directory).

All submissions should include a comment statement near the top of the program of the form:

THIS CODE IS MY OWN WORK, IT WAS WRITTEN WITHOUT CONSULTING A TUTOR OR CODE WRITTEN BY OTHER STUDENTS - your name

Cases of apparent plagiarism or collusion will be referred to the Honor Council.