Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Customers

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 10
At a glance
Powered by AI
The document provides instructions for completing Assignment 2 in the MIS310 course, which involves modifying predefined queries in an Access database.

The document outlines the steps students need to take to complete Assignment 2, which involves modifying predefined queries in a Northwind database to display the correct results.

The steps are to download and open the Northwind database, enable content, modify the predefined queries to display the correct results, and submit the completed database without zipping it.

MIS310 Assignment 2 --- 10 points 2013 Spring

Due Date: April 9, 5:00 P.M.. Points will be deducted for late submission.

How to get started. Check out the video at http://www.youtube.com/watch?


v=UdKVjHg1FSE It will help tremendously.

You need to use Microsoft Access 2007 or 2003 to complete this project. Access is
installed on most of computers at CI computer labs and you can also borrow one from the
library. Through MSDN program, I have set up an account (you should have received an
email from Dreampark) for you to download Access 2007 for PC running Windows, please
find out more about it http://faculty.csuci.edu/minder.chen/mis310/MSDNAA.aspx

Download the database zip file. Unzip it (You may use 7-zip at http://www.7-zip.org/ if
you don’t have the tool to unzip the file). Rename it according to the guideline. Open
the unzipped northwind database. Enable the content under security alert. Start
working on the predefined dummy queries by modifying them. Save these queries after
you are done under the same query name. In Q12, you also need to perform 4 tasks: (1)
create a department table, (2) a simple data entry form, (3) a relationship, and (4) a
master-detail form. Submit the completed database (don’t ZIP it) back to me via
Blackboard system's: Assignment 2 under Content.

Submission:

1. Download the zipped database Northwind, unzipped it to a folder where you can
easily find it, and renaming it with the following naming convention:
Rename your database Northwind_LastName_FirstName.mdb
Such as Northwind_Chen_Minder.mdb (don’t change the file extension .mdb)
2. Open the database, Click on the Options… button of the Security Warning.

1
You should be seeing Q01… to Q13, and Your Final Score queries under Queries.

3. Choose Enable this content and then click OK button to get started.

2
4. All the queries have been created for you with a dummy SELECT statement.
These queries have the following naming convention:
QNN_MeaningfulNameOfYourQuery where NN is the question number,
01, 02, 03, 04, etc. Such as

Q01_TotalNumberOf_USA_Customers
Q02_MostExpensiveProducts

5. Double click on an existing query that you are working on. You will see the default
“dummy” result of the query showing up.

3
6. Fist make sure that you select the Home Tab (The first tab). Click on the View Icon
at the top-right corner to select either SQL View and Design View to modify the
query such that it will generate the correct query result. Remember to Save the
query under the same name (use Save, instead of Save as) when you are done.

When you close the Query window, the following dialog box show up. Choose yes
to save your asnwer.

7. Submit the completed northwind database by using the Blackboard Content


assignment 2 feature and you do NOT need to zip your .mdb file.

8. You will receive 0.8 for each question from Q1~13 if you have the correct answer.
Question 14 counts for 3.6 points.

9. Grading: You will receive the graded database back to your assignment and then
you can run the “Your Final Score” query in the database to find out your final
score. The grading result and instructor’s comment can be found in the Grading
table.

4
NorthWind Scenerio:

The database contains the sales data for a fictitious company called Northwind Traders, which imports
and exports specialty foods from all around the world.

 Suppliers: Suppliers' names, addresses, phone numbers and hyperlinks to home pages.
 Products: Product names, suppliers, prices and units in stock.
 Categories: Categories of Northwind products.
 Orders: Customer name, order date and freight charge for each order.
 Order Details: Details on products, quantities and prices for each order in the Orders table.
 Employees: Employees' names, titles and personal information.
 Customers: Customers' names, addresses and phone numbers.
 Shippers: Shippers' names and phone numbers.

Q0: Open Grading Table in Data Sheet Mode. In the first two rows, please enter your
email as well as your section number and Last name, first name.

Save it and then close the table.

5
Exercise (Not part of the assignment):
E1: List products that is less than 10 dollars with ProductID, Product Name, and Price.

E2: List products that is between 10 to 20 dollars with ProductID, Product Name, and
Price and sort the result by Price in Decending order.

E3: List products that is less than 10 dollars with ProductID, Product Name, and
UnitPrice and sort the result by UnitPrice in Decending order.

E5: List all the products in Beverages category, with its ProductID, Product Name, and
Price.

E6: What is the average price for all beverages products?

SELECT Avg(Products.UnitPrice) AS AvgOfUnitPrice


FROM Categories INNER JOIN Products ON Categories.CategoryID = Products.CategoryID
WHERE (((Categories.CategoryName)="Beverages"));

=== Beginning of the Assignment Questions ====

Q1: List all the customers from United Kingdom with Company Name and Country
columns. Sorted by Companyr Name in ascending order.

Hint: You need to find out the country code for United Kingdom by studying the country
coulumn of the Customers table.
Q2. How many customers are located in France? Your query should return just a
number representing the number of customers who are located in France. Define a

6
meaningful alias for the resulting column so that the heading says “The total
number of customers in “France”.

Q3: How many unique titles do we have in the employee table?


Hint: You need to create two queries, the first query returned all the unique titles, i.e.,
Q03_UniqueTitles (use the Distinct keyword and use the SQL View to type in the SQL
statement directly (Design View will not work).
Please refer to SQL_MIS310 slide#105~107 for guidance. You cannot use Distinct and Count
together in Access and this is why you have to do it in two related two queries.). The second
query is a query against the first query (i.e., Q03_UniqueTitles) and count the number of
unique titles (Use the aggregate function Count) and the query should return a number. The
second query is named Q03_UniqueTitlles_Count and it has been created for you already.
This query should return a result that is a simple number.

Q4: List all current products (the products that are not discontinued – Discontinued is False to
exclude discontinued products) from the most expensive products to the least expensive ones.

Requirements: Your query should return all products that are not discontinued and sorted by
price from highest to the lowest. The query result should contain Product id, product
name, UnitPrice, and discontinued.

To select only active products, you need to set the criteria under Discontinued column to False
(no quotation) – Discontinued is a Boolean data type. This will allow you to exclude all
discontinued products)

Q5: List all the products by its product ID, Product Name, and UnitPrice (has to be in this
sequence). Sort the query result first by UnitPrice in DESCENDING order, and then by
Product Name in ASCENDING order.

Q6: List all products with the price range between 30 to 50 (>= 30 and <= 50), and Price
(sorted by price in Ascending order). List productID, ProductName, UnitPrice, and
CategoryName of the product.

Hint: You need to JOIN the Product table with the Category table using the cetagroyID in
both tables in order to display categoryName (Not CatgoryID) in the query result.

Q7: List only those products with their inventory below the reordering level. Please list
the product ID, Product Name, UnitsInStock, ReorderLevel, and the shortage amount
(sorted by Shortage amount in Descending order).

7
ShoratgeAmount is a calculated column and it is defined as

ShortageAmount: ReorderLevel - UnitsInStock

Hint: Only list products that that have ShortageAmount > 0

Q8: Please find out all the products with product name start with “Ch”. List the query
result with Product Name, UnitPrice, and UnitsInStock and Sorted by ProductName.

Q9. Total Sales for each customer in October 1996 (based on OrderDate). Show the
result in CustomerID, CompanyName, and [total sales], sorted in [total sales] in
Decending order.
Hint: [total sales] is a calculated field. Limit the query results to order date that is during August 1996. You
need to JOIN customers, order, and [order details] tables. Use the critera to limit OrderDate between
#10/01/1996# and #10/31/1996# for September 1996 sales data.

[Total Sales] is a calculated field defined as the following:

CCur(Sum(([UnitPrice]*[Quantity])*(1-[discount])))

Q10: List all the products total sales amount from 1997?
List the query result by ProductID, ProductName, and Annual Sales Amount for 1997 and
sorted it by Annual Sales in Descending order (the annual sales is a calculated column).
Hint:
1. You need to join several tables to answer this question. (Products, Orders, and
[Order Details])
2. Use the critera of OrderDate between #01/01/1997# and #12/31/1997# to get the
annual sales figure from order table and [order details] table.
3. [Annual Sales] is a calculated column. You need to use the aggregate function Sum( ) to
calculate the annual sales for each product, i.e., the sum of the subtotal (extended price)
of an order item for a product ordered in an order. The calculated column is defined as:
CCur(Sum([Order Details].[UnitPrice]*[Quantity]*(1-[Discount])))

The result will be displayed in currency format and to 2 decimal places.


You need to use Group By for ProductID and ProductName

Q11: Write a SQL Update Statement to change the Compnay Name of the shipper #2
(ShipperID = 2) from 'United Package' to 'DHL' You need to save the query as
Q11_UpdateShipperName. The best way to do this is to use SQL View of the query to
write the SQL Update statement directly.

Q12: Show the two most expensive products that are less than 90 dollars with
ProductID, Product Name, and Unit Price and remerber to sort the result by Unit Price
in Decending order.
Hint: Use Select Top 2 …… to get the top 2 records. (Do this under SQL View)
8
Q13: What is the average product price for products in each product category? Display
category ID, Category name, and average price in each category. Sort by the average
price in Decending order.

Hint: Join the Products and Categories tables and GROUP BY Category Name and use
the aggregate function AVG for average
Q14: (3.6 points)

a. (Add a new table called Department based on the following information (0.5 point):
Table name: Department
Columns:
DepartmentID: Text data type with 5 characters in length
Name: Text data type with 50 characters in length

Define DepartmentID as the primary key of this table. Please enter the following three records
into the newly created database table.

DepartmentID Name
ECON Economics
MIS Management information system
BUS Business

b. (1) Create a new form called Department and then (2) enter Department information
into the Department table. Using the columnar format for the form. The form should
look like the following, and please enter three department names (make up these
Department’s ID and names by yourself) into the table. (0.5 points)

c. Create a relastionship: You need to add a new column called DeptID in the
Employee table, it will be the foreign key in this table, it should be text data type and 5
characters in length. Make sure you enter the corresponding departmentID that you
have entered in the Department table previously (Please enter three department ID as
the following: ECON, BUS, and MIS, MKT). Then, use the Relationships tool under
9
Database Tools to create a relationship between the Department Table and the
Employee table, i.e., connecting the two tables together via the primary key
(DepartmentID in Department Table) and foreign key pair (Deptid in the Employee Table
and choose Enforce Referential Integrity to set the integrity contraint between the
foreign key and primary key. (0.6 point)

d. Create a master-detail form called DepartmentEmployeeForm to view and enter


department’s employee data. The form should look like the following one (0.6 point).

10

You might also like