You are on page 1of 2

CSci 2030-51

Fall 2018

Assignment 4
Deadline 11/19/18 by
11:59pm

This is a small group assignment. You get grades for the task(s) where you not just participated
but completed on-time the part of work your agreed to do, without forcing your peers to quickly
do it for you. You should also check your peers’ work and give a timely feedback so that they
would fix the errors you detected.

Each student has to make a contribution to both tasks’ completion. More overlapping creates a
stronger opportunity to catch errors and improve overall quality.

Have you heard about pair programming? If not, find more about this technique on the Web.
Software quality increases when a peer is watching you when you code and questioning from
time to time why you are doing it this particular way.

Similarly, this team work is not about reducing your share to 1/3 of what would it take to solve
the problems alone. Rather, it's about quickly organizing the joint brainstorming and triple-
checking the solutions. It can be done remotely in this class unless the entire group prefers to
meet on-the-ground. Setting up some kind of quality assurance would reduce the risk of
losing points by everyone in the team.

I created a “locker” for each group, to be used as a joint repository. Also, you have access to
WebEx conferencing platform. It has more capabilities than free video conferencing tools
like Skype or WhatsUp. For example, you can text to other participants and share your
computer screen with other team members.

The two databases you are dealing with are relatively small, well below what is typical in
production environment. You can only rely on the database schema to remain stable.
However, you should not create queries that would lead to wrong results when the data
changes. For example, what if a new publisher will be added to the database or one of the
existing ones will be removed?

Task 1 (27 points) A management company provides business services for Westex, a group
of publishers. It uses a Pubs database for their affairs with authors and stores. They decided to
determine which are the most profitable titles published by each of their member companies.
Your goal is to enhance the database to accomplish this and record the results.

Profit for each title is defined as the total revenue (its price times quantity sold) minus royalties
and advances. Royalty rate (stored in per cents) is the share of the book’s sale proceeds paid to
the author. No discounts are taken into consideration. Quantity sold is recorded in Pubs in the
column with a (misleading) name ytd_sales. An advance is expressed as a single lump sum.
Write and add to Pubs a stored procedure named StartMostProf (without parameters) that will
be called once to do the following job:

• Add a table most_prof to pubs with three columns where pub_id, top_profit
and date_time would be recorded for each company;
• for each publishing company found in Titles table, adds a row to the table
most_prof, and populate it based on the current data in the database.

This sproc is not supposed to be used for further updating of most_prof table.

By the deadline, each group member who worked on this task should (on their personal NHCC
server account) add StartMostProf stored procedure to Pubs database. If, for testing purposes,
most_prof table was created, please delete it by the deadline, so that I it will be created without
any diagnostic message when I running your sproc for grading.

Task 2 (23 points) The enterprise which business is reflected in your Northwind database
decided to research which of the listed suppliers has the lowest total revenue based on all the
recorded orders.

Write a user-defined scalar function MinSupplier that outputs a single value: the name of such a
supplier. If more than one supplier meets this criterium, name a random one among those
candidates. Though the current data may not reflect such a case, still make MinSupplier be
prepared to process it correctly. You may need to research the functions available on SQL
Server.

By the deadline, each group member who worked on this task should add the function to their
Northwind database on NHCC SQL Server.