336x Filetype DOCX File size 0.23 MB Source: f01.justanswer.com
The management of KimTay Pet Supplies (a supplier of pet supplies, food, and accessories located in
Cody, Wyoming) has determined that the company’s recent growth no longer makes it feasible to
maintain customer, invoice, and inventory data using its manual systems. In addition, KimTay Pet
Supplies wants to build an Internet presence. With the data stored in a database, management will be
able to ensure that the data is up-to-date and more accurate than in the current manual systems. In
addition, managers will be able to obtain answers to their questions concerning the data in the database
easily and quickly, with the option of producing a variety of useful reports.
The CUSTOMER table maintains information about each customer, such as their ID, first and
last name, address, balance, and credit limit.
In the INVOICES table contains information about each invoice, such as the invoice number,
date, and the customer being invoiced.
The INVOICE_LINE table has the itemized information for each invoice. This includes the item
ids, quantity, and price for each invoice.
The ITEM table has a information pertaining to each item for sale by KimTay's Pet Supplies.
This includes a description, the number in stock, location, and price.
The SALES_REP table includes the information for each sales representative for KimTay's Pet
Supplies. This includes first and last name, address, cell-phone, commission, and commission
rate.
Task 1: Create a VIEW named MAJOR_CUSTOMER. It consists of the customer ID, first
name, last name, balance, credit limit, and rep ID for every customer whose credit limit
is $500 or less.
CREATE VIEW MAJOR_CUSTOMER AS
SELECT CUST_ID, FIRST_NAME, LAST_NAME, BALANCE, CREDIT_LIMIT,
REP_ID
FROM CUSTOMER
WHERE CREDIT_LIMIT <= 500;
SELECT * FROM MAJOR_CUSTOMER
Task 2: Write and execute the command to retrieve the customer ID, first name, and last name
of each customer in the MAJOR_CUSTOMER VIEW with a balance that exceeds the credit
limit.
SELECT CUST_ID, FIRST_NAME, LAST_NAME FROM MAJOR_CUSTOMER
WHERE BALANCE > CREDIT_LIMIT
Task 3: Without using the MAJOR_CUSTOMER VIEW, retrieve the customer ID, first name,
and last name for every customer whose credit limit is $500 or less.
SELECT CUST_ID, FIRST_NAME, LAST_NAME
FROM MAJOR_CUSTOMER
WHERE CREDIT_LIMIT <= 500
Task 4: Create a VIEW named ITEM_INVOICE. It consists of the item ID, description, price,
invoice number, invoice date, quantity, and quoted price for all invoice lines currently on file.
CREATE VIEW ITEM_INVOICE AS
SELECT ITEM.ITEM_ID, ITEM.PRICE, INVOICES.INVOICE_NUM,
INVOICES.INVOICE_DATE, INVOICE_LINE.QUANTITY,
INVOICE_LINE.QUOTED_PRICE
FROM ITEM
INNER JOIN INVOICE_LINE ON INVOICE_LINE.ITEM_ID = ITEM.ITEM_ID
no reviews yet
Please Login to review.