SlideShare une entreprise Scribd logo
1  sur  43
City Home Cover
Page
Team Members:
Nadine Miller
Chris Morgan
Yuri Voronyuk
MIS 372
December 10th, 2016
ii
Executive Summary
City Home is a privately owned vintage, antique and industrial furniture business that buys and
sells reclaimed furniture. City Home originally did not have an automated system to keep track of
their work shop and sales process. City Home was recording everything manually in Excel which
was very time-consuming and did not allow for much analysis. The operational database
documented here is designed to support the entire work shop and sales process for the products
at City Home. By keeping track of the initial purchase price of each product, the cost of materials
and services required to repurpose or refurbish the product, and the sale price, City Home can
ensure they are generating profit.
The key processes which generate and store data in the database include inspecting the product,
assigning a work order, setting a price and generating a sales invoice. In addition, materials can be
ordered for the workshop. To effectively capture data from these processes a normalized data
schema includes a table for products, customers, employees, materials, vendors, the recording of
the work order transactions and the sales invoice transactions, among many others.
The key goal for City Home’s operational database was to effectively keep track of profits in a
timely and efficient manner. To eliminate data redundancy and prevent anomalies, the database
uses primary and foreign keys. In addition, referential integrity is enforced with relationships
connecting all the tables to each other – as depicted in the database diagram. In order to support
efficient management and ensure the company is generating profit effectively, two reports are
developed. The first report is the work order report which includes details about a particular
product. The report includes the purchase price, the employee labor cost(s) and materials cost to
generate a total cost of repurposing and refurbishing the item. The second report is the sales staff
activity report which includes sales information about each sales employee. The report includes
the employee’s first name, total sales, average sales and the number of sales. The report also
generates a total to keep track of sales between a particular date range.
In such a fast paced environment the need for an operational database was necessary. City Home
will now be able to keep track of their data more effectively and efficiently and ensure that they
are maintaining their ultimate goal – to preserve the history and reduce a carbon profit all while
running a profitable business.
iii
Tabl eof Contents
Table of Contents
CITY HOME COVER PAGE I
EXECUTIVE SUMMARY II
TABLE OF CONTENTS III
REVISIONS AND REPORTS 1
NARRATIVE 1
ORGANIZATIONAL OVERVIEW: 1
PROCESS OVERVIEW: 1
DETAILED PROCESS DESCRIPTION: 2
ENTER NEW PRODUCT: 2
SEND TO INSPECTION: 2
SEND WORK ORDER TO WORKSHOP AND FULFILL WORK ORDER: 2
CREATE QR CODE: 3
SET PRICE: 3
PRINT QR CODE AND CREATE PRODUCT SHOWCASE: 3
SELL PRODUCT: 3
BUSINESS PROCESS END 3
LIST OF TRANSACTIONS AND OBJECTS WITH ATTRIBUTES: 4
OBJECTS: 4
TRANSACTIONS: 4
FLOW CHARTS 5
CITY HOME BUSINESS PROCESS 5
CITY HOME INSPECTION SUB PROCESS 6
CITY HOME WORK ORDER SUB PROCESS 7
CITY HOME SALES SUB PROCESS 8
ENTITY-RELATIONSHIP (E-R) DIAGRAM 9
E-R DIAGRAM FOR CITY HOME 9
CARDINALITY CONSTRAINTS: 9
DATA TYPES: 10
DATA DIAGRAM 11
CITY HOME DATABASE SCHEMA: 11
DESIGN EXPLANATION 12
OBJECT TABLES 12
TRANSACTION TABLES 12
EXAMPLES OF CALCULATED DATA 12
PRJ2 WORK ORDER REPORT 12
REPORT DOCUMENTATION: 12
WORK ORDER REPORT 13
iv
SQL QUERIES 13
REPORT HEADER 13
FIRST PART OF REPORT 14
SECOND PART OF REPORT BODY 14
PRJ3 SALES STAFF ACTIVITY REPORT 15
REPORT DOCUMENTATION: 15
REPORT PROCEDURE 15
SQL STORED PROCEDURE QUERIES 16
SALES STAFF ACTIVITY REPORT 16
UPDATED PRJ2 EXAMPLE DATA 17
DATABASE SCRIPT 25
1
Revisions and Reports
Narrative
Organizational Overview:
City Home is a privately owned vintage, antique and industrial furniture business that buys and
sells reclaimed furniture. Located in the heart of downtown Portland, City Home buys used
furniture from local antique stores, flea markets, garage sales, estate sales and private parties.
City Home consists of two warehouses, a workshop and a store front.
All furniture is purchased locally in the Portland area and placed in the store for resale. However,
before being placed for sale in the store, most products undergo some kind of change. Nearly 80%
of the products need to be refurbished or repurposed. City Home originally had no way to record
their business process so it was difficult to determine which products generated the most profit.
City Home will now be more efficient and be able to track costs as they pertain to each product. It
also holds all employees accountable for the work they are doing, whether it is inspecting the
product, working on the product, or selling the product.
City Home buys nearly 300 unique pieces of furniture each month and sells approximately 8 a day.
Profit is generated by purchasing products at a very low price, improving or changing the product
using materials and services, and selling the product for more than the adjusted basis and the
work done to it. Some products are even immediately marked up and ready for resale. The main
goal at City Home is to make profit but also promote the use of salvaged and reclaimed materials
in order to preserve the history of such products and to reduce a carbon footprint.
Process Overview:
City Home’s product as-is, refurbish, repurpose and resale process involves the product, an
employee, a workshop employee and possibly an appraiser. The primary purpose of the process
is to record initial details about each product that enters the warehouse and the process it
undergoes before it is ready for resale. While some products do not need any work and are
immediatelyplacedinthe store, most products need to be repairedor repurposed. Thisis decided
by our professional inspectors who inspect each product carefully before deciding what needs to
be done to it. The inspection employee then creates a work order. The product is later sent to our
workshop where our workers spend hours carefully refurbishing or repurposing each product
whilestill keeping the original productsintegrityandunique style. Thisinspection process is usually
completed within a day and the workshop process within a week.
An appraiser will be contacted in order to help determine a price if it cannot be determined by the
workshop. QR codes are created to track product in warehouse. QR codes make it easy to track
product movements and gives locations. Due to limited space in the store and the size of most
products, they cannot be displayed in store. Customer can scan the code to access more photos
of the product and a detailed description of the Product. Once the product is ready for sale and a
price has been assigned a showcase is built to give customers a small preview of the product and
2
a place to Scan the QR Code. Customer may check out with a sales associate or with their smart
phones. Invoice is sent to appropriate warehouse to alert warehouse employees to prep product.
Once Product is picked up by customer or shipped to customer the full process has been
completed.
Detailed Process Description:
City Home recently adopted a new automated process to keep track of when a product enters the
warehouse for the first time and what is done to it in order for it to be placed for sale in the store.
This process not only tracks important information about each individual product, but also the
costs associated with getting the product ready for sale in order to find profit.
Enter New Product:
New product enters the City Home warehouse. The product is catalogued.A product id is assigned
to the product. The product type, condition and purchase price are also recorded. Product
informationis sent to the Data Store. The maingoal of recording this initial informationisto record
purchase price in order to later determine profit after the product has been worked on and sold.
After the product has entered the warehouse and been catalogued, it is sent to inspection.
Send to Inspection:
Once the product has been sent to inspection, the inspection employees carefully look at the
product and decide whether or not the product is immediately ready for resale – meaning nothing
needs to be changed, only a price needs to be assigned – or if the product needs to be refurbished
or repurposed. If it is ready for resale, an inspector sets the price, has the QR code created, and
the product information is sent to the sales department. If the product needs to be refurbished or
repurposed, it is recorded on the work order and the work order is sent to the workshop with the
product. Work Orders are sent to the Data Store.
Send Work Order to Workshop and Fulfill Work Order:
Work order is sent to the workshop. A workshop employee will observe the product and the work
order and decide what materials and services are needed to refurbish or repurpose the product.
Workshop employee decides what materialsareneededto work on the product. Materialsinclude
but are not limited to nails, bolts, tools, sandpaper, paint, replacement pieces, fabric, etc. Cost of
materials is recorded. If a certain material is unavailable it is ordered. Workshop employee also
records services done to the product. Services include but are not limited to sanding, painting,
carpentry work, etc. Hours of work is also recorded with the hourly wage to keep track of how
much is going in to the repurpose or refurbish process of the product.
3
Create QR Code:
After the work order isfulfilled,a QR is created.A QR Code is specific to each product. The purpose
of the QR code is to track the product after it has been refurbished or repurposed and as it goes
through the appraisal and sales process.
Set Price:
After the completion of the work order, a price must be assigned. However, the workshop decides
whether or not the product needs to be appraised. If the product does not need to be appraised,
the workshop determines a price for the product. If the product needs to be professionally
appraised, say for historical purposes, or if the product has been entirely turned into a new type
of product, a professional appraiser is outsourced and comes to the workshop to giveanappraisal.
The workshop assigns a pricebased on the appraisal.Once a price has been assigned each product
in the Data Store now includes not only the purchase price but also the sale price. The QR code is
then updated to include the price for customer viewing.
Print QR Code and Create Product Showcase:
The QR code for each product must be printed so that customers can scan the product if they
wish. For each product a showcase is created in the store for customers to see pictures,
description, and scan a QR code of the product.
Sell Product:
Once a customer chooses a particular product for purchase and its delivery type (a pick-up from
the Warehouse or shipping to home address), they scan the QR code using an app on their
Smartphone to launch checkout. If the customer is new to the store, the system adds their
information to the Customers table in the DataStore. If the customer already exists in the
DataStore, their information is used to generate a new invoice. Invoices exist in a DataStore as a
separate table. After the invoice is generated, customer makes a payment. After the sale is
finalized, customer receives an e-receipt via e-mail. The invoice is then sent to Warehouse, where
the product is prepared either for the pick-up or shipment, depending on the customer’s
preference. When the product is prepared for a pick-up, the customer may come and receive it
any time during working hours. When the product is shipped out, the customer should expect to
receive it in 6-10 business days.
Business Process End
The business process ends when the product has been sold. The whole purpose of this process is
to record every stage the product undergoes and the cost associated with doing so in order to
generate profit. Purchase price, cost of materials used, and hours of services done (hourly wage x
hours worked) and sale price will determine the profit.
4
List of Transactions and Objects with Attributes:
Objects:
Product is a person, place or thing so it is an object. Products are the most important object in this
process. The products have several attributes that rarely change. A product list is maintained
including product, product type, product condition and product cost.
Employee is a person, so it is an object. An employee list is maintained including employee name
and position. Position is included to specify whether the employee is an inspection employee,
workshop employee or sales employee.
Customer is a person, so it is an object. A customer list is maintained including customer name,
email and phone number. Customers purchase the products.
Material is a thing, so it is an object. A material list is maintained including material cost,
description and vendor. Materials are ordered to be used to fulfill work orders.
Transactions:
The work order, which is created by an inspection employee in order to determine what the
workshop will do to the product, is a transaction. City Home wants to track the attributes for each
work order and every work order is different because every piece of furniture (the product)
received is different and needs a different kind of work. Work order includes the inspection
employee who created the work order, the product being worked on, work order date, whether
the product needs to be refurbished or repurposed, total material cost, hours worked, and
completion date. These details are recorded once, on a single work order, for a single product.
Once the work order is complete, the data does not need to be changed. It is complete and at that
point the product is complete.
The invoice, which is created by a sales employee in order for a customer to purchase a product,
is a transaction. City Home wants to track the attributes for each invoice, and every invoice is
different because of every product purchased is different and every customer that makes a
purchase is different. Invoice includes the customer who is making the purchase, the sales
employee creating the invoice, the product(s) being purchases, delivery type, and price. The
detailsof the invoice arerecordedonce, on a singleinvoice,for a singlecustomer.Once the invoice
is complete and the sale has been made, the data does not need to be changed. It is complete.
The material order, which is created by an employee in order to purchase materials needed to
work on the products is a transaction. City Home wants to keep track of costs associated with
refurbishing and repurposing an item, therefore there must be a way to record costs of materials
used. The materials order includes
5
Flow Charts
City Home Business Process
CITY HOME BUSINESS PROCESS
Data StoreWarehouse Inspection Workshop Appraiser Sales
Acquire New
Product
Catalog
Product
Send To
Inspection
Complete
Inspection
Send Work Order
To Workshop
Fulfill
Work Order
Send to
Appraiser
Set Price
Need
Appraisal
Workshop
Sets
Price
Appraise Product
Update Price
In QR Code
Print QR
Code
Create Product
Showcase
Create QR
Code
Invoices
Products
Work Orders
Products
Products
Sell Product
Figure 1 shows the main City Homebusiness process. It tracks the Product from the time it enters the warehouseuntil the product
is sold. The purpose of this process is to track costs associated with the product and the final sale price in order to determine the
profit made. City Homeoriginally did not have any kind of automated process to record inspection of the product or work done to
each product.
6
City Home Inspection Sub Process
City Home Inspection Sub Process
Data StoreWorkshopWarehouse Employee
Inspect
Product
Create
Work Order
Send Product
To Workshop
Needs
Work Done
Work Orders
Receive
Product
Products
Product
Ready
For
Sale
Set Sale Price
Request
Inspection
Store
Product
Figure 2 shows the inspection sub-process. The inspection process tracks the product from the time it enters inspection until the
time it is sent to the workshop with a work order. Note: If the product does notneed to be refurbished or repurposed it is immediately
ready for resale, an inspection employee sets the price and the product is sent back to the warehouse.
7
City Home Work Order Sub Process
City Home Fulfill Work Order Sub Process
WorkshopWarehouse Vendors Data Store
Send Product to
Workshop
Receive
Product
Access
Work Order
Order
Materials
Repair
Product
Need
Materials
Materials
Available
Send
Materials
Work Orders
Create QR Code
Complete
Work Order
Return Product
Warehouse
Accept
Product
Products
Work Orders
Products
Record Services and
Hourly Wage
Figure 3 shows the sub process of fulfilling the work order. Within the sub-process materials may be order, QR codes created for
finished products, and products is returned to warehouse. Employees also track there hours worked to repair or refurbish the
product.
8
City Home Sales Sub Process
City Home Sales Sub Process
CustomerSales Warehouse Data Store
Create Product
Showcase
Scan QR Code
Checkout
Add Customer
Create Invoice
Pay Invoice
Finalize Sale Receive Invoice
Ship ProductReceive Product
Prepare Product for
Pick-up
Products
Customers
Invoices
Pick-up
Produuct
e-receipt
Existing
Customer
New
Customer
Products
Ship
Product
Figure 4 shows the sales sub-process. The sales process tracks the product from the time it is showcased until the time it is
purchased by and shipped to customer.
9
Entity-Relationship(E-R) Diagram
E-R Diagram for City home
Figure 5 is the entity-relationship diagram for City Home. It includes four objects and two transactions. Objects include
employee, item, customer, and material. Transactions include work order and invoice.
Cardinality Constraints:
 Each employee has a unique id, title, first and last name, phone number, hire date and
hourly wage.
 Eachproduct has a unique id(product name),product condition id,amount purchased and
purchased price.
 Each customer has a unique id, first and last name, address, and phone number.
 Each material has a unique id, vendor id, unit of measure id, list price and description.
 Each inspection employee can inspect one or many items. However, employee represents
several positions – inspection employee, workshop employee and sales employee. Each
sales employee can create one or many invoices. Each workshop employee can fulfill one
or many work orders.
 Each product can be inspected by one or many inspection employee. Each product can be
assigned to one work order. Each product can be purchased by one customer and multiple
customers can purchase multiple products.
 Each customer can buy one or many products and a customer can be assigned to one or
many invoices.
 Each material can be ordered to fulfill one or many work orders, but one work order may
or may not need materials.
10
Data Types:
 Employee (object) data used to record details of the employee
o EmployeeID – integer, unique identifier [primary key]
o Title – text
o Last name, first name – text
o PhoneNumber – integer
o HireDate – date
o HourlyWage – decimal
 Work order (transaction) data used to record details of the work order
o WorkOrderID – integer, unique identifier [primary key]
o EmployeeID – integer [foreign key]
o ProductID – integer [foreign key]
o WorkOrderDate – date
o EmployeeHours – decimal
o EmployeeCost – money
o TotalMaterialCost – money
o TotalCost – money
 Product (object) data used to record details of the item
o ProductName – text, unique identifier [primary key]
o ProductConditionID – integer [foreign key]
o AmountPurchased – integer
o PurchasedPrice – money
 Invoice (transaction) data is used to record details of the invoice
o SalesInvoiceID – integer, unique identifier [primary key]
o CustomerID – integer, unique identifier [foreign key]
o EmployeeID – integer, unique identifier [foreign key]
o SalesDate – date
o SubTotal – money
o Discount – integer
o ShippingCost – money
o TotalDue – money
o DeliveryMethodID – integer [foreign key]
 Customer (object) data is used to record details of the customer
o CustomerID – integer, unique identifier [primary key]
o LastName – text
o FirstName – text
o Address – text
o City – text
11
o State – text
o ZipCode – integer
o PhoneNumber – integer
o YTDPurchased – money
 Material (object) data is used to record details of the material
o MaterialsID– text, unique identifier [primary key]
o VendorID – integer [foreign key]
o UnitOfMeasureID – integer [foreign key]
o ListPrice – money
o Description – text
Data Diagram
City Home Database Schema:
Figure 6 is the database diagram for City Home’s work order and sales process.
12
Design Explanation
Object Tables:
Products, Employees, Materials, Customers and Vendors are object tables because they are
people or things that are involved in many transactions or events.
Transaction Tables:
WorkOrder is a transaction table because it records the event of assigning a work order to a
product, working on the product, and costs associated with working on the product. SalesInvoice
is a transaction table because it records sales events.
Examples of Calculated Data:
YTDSales in the Vendors table is calculated as the sum of all sales from each vendor for the year
and YTDPurchases in the Customers table is calculated as the sum of all purchases made by each
customer for the year. Other calculated data includes LineTotal in the InvoiceDetailstable,
TotalDue in the SalesInvoices table, TotalCost in the WorkOrders table and TotalPrice in
WorkOrderDetails.
PRJ2Work Order Report
Report Documentation:
The work order report is created in order to track details about work done to a specific product
using certain materials. The purpose of the work order is to primarily record costs associated with
refurbishing or repurposing a product. Work order details areimportantbecause it specifieswhich
materials were used to work on the product and at what cost. The work order is basically the focal
point of CityHome’s workshop process and necessary indetermining profit and loss after the sales
process. The final work order report can be generated once the product is inspected, assigned a
work order, the work order is sent to the workshop, and materials are ordered and used to work
on and recreate the final product – so basically the product must have undergone the entire
workshop process before the report serves a purpose. More specifically on our flow chart, data
included in the report isa result of the following:“Inspect Product,” “Assigna Work Order,” “Fulfill
Work Order.” The product must be assigned a condition – either ready for sale, needs to be
repurposed, or needs to be refurbished. If the product needs to be refurbished or repurposed, it
has been assigned a work order and sent to the work shop for the work order to be fulfilled. The
work order is fulfilled by including employee hours and materials needed.
At City Home, an inspector will review all the work orders before the price is officially assigned to
the product to ensure that everything was done correctly and to ensure that City Home is actually
13
making profit on the products they refurbish or repurpose. The report contains two sections: a
report header and a report body. The report header contains information about a given work
order, such as the work order ID, product ID, employee ID, work order date, employee hours, total
material cost, and total cost. The report body displays details of the work order such as which
materials were ordered, quantity of materials ordered, unit price, and total price.
Work Order Report
City Home - Work Order Report
Work Order #: 1
Date: 1/1/2016
Product Name: Desk
Product Purchase Price: $30.00
Total Work Order Cost: $411.97
Employee Information
Name Title Hourly Wage Hours Cost Work Date
Yogi Baggins Inspector $30.00 1 $30.00 1/1/2016
Mark Westin Workshop Worker $20.00 4 $80.00 1/3/2016
Greg Mullins Supervisor $25.00 2 $50.00 1/3/2016
Emily Westin Workshop Worker $20.00 2 $40.00 1/12/2016
Russell Wilson Appraiser $45.00 1 $45.00 1/25/2016
Material Information
Material Name Order Quantity Unit of Meas. UnitPrice
Total
Price
Order
Date
Stain 2 oz $30 $60.00 1/3/2016
Wax 1 lb $16.97 $16.97 1/12/2016
Hinge 1 ea $90.00 $90.00 1/20/2016
Figure 7 shows the details for a specific work order – work order number 1.
SQL Queries
Report Header “Work Order Header” Query
SELECT TOP (100) PERCENT dbo.WorkOrders.WorkOrderID AS [Work Order #],
dbo.WorkOrders.WorkOrderDate AS [Work Order Date], dbo.Products.ProductName AS
[Product Name], dbo.WorkOrders.TotalRepairCost AS [Total Repair Cost]
FROM dbo.WorkOrders INNER JOIN
dbo.Products ON dbo.WorkOrders.ProductName = dbo.Products.ProductName
WHERE (dbo.WorkOrders.WorkOrderID = 1)
14
Work Order # Work Order Date Product Name Total Repair Cost
1 1/1/16 Desk 360.97
Table 1displays the information required for the heading of the work order report.
First Part of Report “Work Order Materials” Query
SELECT TOP (100) PERCENT dbo.WorkOrderMaterials.OrderDate AS [Order Date],
dbo.Materials.MaterialName AS [Material Name], dbo.WorkOrderMaterials.OrderQty AS [Order
Quantity],
dbo.Materials.UnitOfMeasureID AS [Unit Of Meas.],
dbo.WorkOrderMaterials.UnitPrice AS [Unit Price], dbo.WorkOrderMaterials.TotalPrice AS
[Total Price]
FROM dbo.WorkOrderMaterials INNER JOIN
dbo.Materials ON dbo.WorkOrderMaterials.MaterialName =
dbo.Materials.MaterialName
WHERE (dbo.WorkOrderMaterials.WorkOrderID = 1)
ORDER BY [Order Date]
Material Name Order Date Order Quantity Unit Of Meas. Unit Price Total Price
Stain 1/3/16 2 oz 30 60
Wax 1/12/16 1 lb 16.97 16.97
Hinge 1/20/16 1 ea 90 90
Table 2 displays the information required for the second part of the work order report body – the material information.
Second Part of Report Body “Work Order Labor” Query
SELECT TOP (100) PERCENT dbo.Employees.Title, dbo.Employees.LastName AS [Last
Name], dbo.Employees.FirstName AS [First Name], dbo.WorkOrderLabor.WorkDate AS [Work
Date], dbo.WorkOrderLabor.Hours,
dbo.Employees.HourlyWage AS [Hourly Wage],
dbo.WorkOrderLabor.EmployeeCost AS [Employee Cost]
FROM dbo.Employees INNER JOIN
dbo.WorkOrderLabor ON dbo.Employees.EmployeeID =
dbo.WorkOrderLabor.EmployeeID
WHERE (dbo.WorkOrderLabor.WorkOrderID = 1)
ORDER BY [Work Date]
15
Title Last Name First Name Work Date Hourly Wage Hours Employee Cost
Inspector Baggins Yogi 1/1/16 30 1 30
Workshop Worker Westin Mark 1/3/16 20 4 80
Supervisor Mullins Greg 1/3/16 25 2 50
Workshop Worker Westin Emily 1/12/16 20 2 40
Appraiser Wilson Russell 1/25/16 45 1 45
Table 3 displays the information required for the third part of the work order report body – the employee information.
PRJ3Sales Staff Activity Report
Report Documentation:
The sales staff activity report is generated in order for us to see how many sales each employee
makes in a given period. The report consists of two parts and contains an employee’s first name,
dollar amount of total and average sales, the number of sales by an employee in a given period,
and the total amount of allsales and its total dollar amount. The report is important to City Home
as the shop strives to generate as many sales as possible. Employees with the greatest generated
revenue are encouraged to mentor their fellow co-workers by sharing stories of successful sales.
This report is also valuable in terms of determining which employees might deserve a bonus or a
raise at the end of the year, or should be more motivated.
Lastly, knowing the total amount of sales is crucial in understanding where City Home is standing
financiallyand what possiblechanges should be made in order to meet its financialgoals.Because
the report can be generated for a particular period, it is easy for City Home to see how sales
activity changes from one period to another, which is important when planning a budget, or
simply for the record keeping purposes. This particular report is focusing on the last two years of
City Home’s operations and lists six employees and their sales statistics. Understanding where
the company stands financially is key to having a successful business.
Report Procedure “To Date Sales” Query
USE [CityHome02] --Shows the database we are using
GO
CREATEPROCEDURE [dbo].[SalesWithTotalsPRJ] --Name of the stored procedure
(--Input parameters are a date range
@startDateasDateTime,
@endDateasDateTime
)
AS--Main body of the report
SELECTTOP (100)PERCENTdbo.Employees.FirstName,
SUM(dbo.SalesInvoices.SubTotal)AS [Total Sales],--aggregation by the sum
AVG(dbo.SalesInvoices.SubTotal)AS [Average Sales],--aggregation by the average
16
COUNT(dbo.SalesInvoices.SalesInvoiceID)AS [Number of Sales] --aggregation by count
FROMdbo.EmployeesINNERJOINdbo.SalesInvoices
ONdbo.Employees.EmployeeID=dbo.SalesInvoices.EmployeeID
WHERE (dbo.SalesInvoices.SalesDate>=CONVERT(DATETIME, @startDate, 102))--filter for the start date
AND(dbo.SalesInvoices.SalesDate<=CONVERT(DATETIME, @endDate, 102))--filter for the end date
GROUPBYdbo.Employees.FirstName--Aggregator for grouping
ORDERBYSUM(dbo.SalesInvoices.SubTotal)DESC--result set by descending order
--The totals table
SELECTTOP (100)PERCENT
SUM(SubTotal)AS [Total Sales],--aggregation by the sum
AVG(SubTotal)AS [Average Sales],--aggregation by the average
COUNT(SalesInvoiceID)AS [Number of Sales] --aggregation by the count
FROMdbo.SalesInvoices
WHERE (SalesDate>=CONVERT(DATETIME, @startDate, 102))--filter for the start date
AND(SalesDate<=CONVERT(DATETIME, @endDate, 102))--filter by the end date
ORDERBYSUM(SubTotal)--result set by descending order
SQL Stored Procedure Queries
This query generates two result sets: the report body and the totals table. It uses date range as
an input parameter in order for the user to specify the period for which the report is generated.
This is done by the WHERE filter parameter. The query uses SUM aggregator to produce total
sales by an employee, AVG aggregator to produce average sales dollar amount set, and COUNT
to show the number of invoices a particular employee has made in that period. The query also
uses GROUP BY to aggregate sales data by employee, and organizes the order of the result set
with ORDER BY, in this case the SUM, or total sales, in descending order. The full query is
presented below.
Sales Staff Activity Report
City Home - Sales Staff Activity Report
From 1/1/2014 to 12/31/2016
First Name Total Sales Average Sales Number of Sales
Jennifer $4,150.00 $2,075.00 2
Abby $1,740.00 $580.00 3
Yogi $1,500.00 $750.00 2
Angus $1,360.00 $680.00 2
Ralph $600.00 $600.00 1
Marge $150.00 $150.00 1
Total: $9,500.00 $863.64 11
Figure 8 show the sales staff activity report for City Home for the data 1/1/2014 to 12/31/2016.
17
Updated PRJ2Example Data
Product Name Table
ProductName AmountPurchased PurchasedPrice ProductConditionID
Armoire 1 70 S
Bookshelf 2 80 RP
Broken Couch 1 0 PRT
Broken Desk 1 0 PRT
China Hutch 1 100 RP
Clock 2 8 S
Coffee Table 1 50 S
Couch 1 100 RF
Desk 2 30 RF
Desk Chair 2 25 S
Dresser 1 53 S
Grandfather
Clock 1 45 S
Lamp 3 45 S
Lantern 1 12 RF
Mirror 1 40 S
Night Stand 3 100 S
Table 4 contains data for the Products table. Yellow highlights show that one ProductConditionID can appear many times.
Product Condition Table
ProductConditionID Desription
PRT Product used for parts
RF Product needs to be repaired before Sale
RP Product is turned into new product
S Product is ready for sale
Table 5 contains data for the ProductCondition table.
18
Work Order Labor Table
WorkOrderLaborID EmployeeID WorkOrderID WorkDate Hours EmployeeCost
1 8 1 1/1/16 1 30
2 5 1 1/3/16 4 80
3 1 1 1/3/16 2 50
4 4 1 1/12/16 2 40
5 12 1 1/25/16 1 45
6 8 2 6/14/16 1 30
7 4 2 6/22/16 3 39
8 1 2 7/9/16 2 50
9 12 2 7/20/16 1 45
10 4 3 8/16/16 2 40
11 8 4 8/20/16 1 40
12 5 4 9/30/16 4 80
13 8 5 9/14/16 1 30
14 12 5 9/20/16 1 45
Table 6 13 contains data for the WorkOrderLabor table.
Work Order Table
WorkOrderID ProductName WorkOrderDate TotalEmployeeCost TotalMaterialCost TotalRepairCost
1 Desk 1/1/16 200 166.97 360.97
2 Bookshelf 6/14/16 240 280 520
3 Broken Desk 8/16/16 40 45.96 85.96
4 Desk 8/20/16 100 180.05 280.05
5 Coffee Table 9/14/16 75 0 75
Table 7 contains data for the WordOrder table. Yellow highlights demonstrate that one ProductName and one EmployeeID can appear many times.
19
Work Order Materials Table
WorkOrderMaterialsID WorkOrderID OrderDate MaterialName UnitPrice OrderQty TotalPrice
1 1 1/3/16 Stain 30 2 60
2 2 6/22/16 Nails 10 2 20
3 2 6/23/16 Mirror 250 1 250
4 1 1/12/16 Wax 16.97 1 16.97
5 3 8/10/16 Sand Paper 8.99 4 35.96
6 4 8/22/16 Trimming 13.85 13 180.05
7 1 1/20/16 Hinge 90 1 90
8 2 6/30/16 Small Nails 5 2 10
9 3 8/12/16 Nails 10 1 10
Table 8 contains data for the WorkOrderMaterials table.
Materials Table
MaterialName VendorID UnitOfMeasureID ListPrice Description
Bolts 2 ea 1.99 3 inch Bolts
Cable 5 Ft 1.34 14 gauge
Crews 1 bx 12.99 One inch
Hinge 3 ea 90 Special three-way hinge
Mirror 3 ea 250 Star shaped
Nails 1 bx 10 Ten Penny
Nuts 2 ea 0.45 Match 3 inch Bolts
Paint 4 oz 15 Egg shell white
Sand Paper 2 ea 8.99 Extra Fine
Small Nails 1 dz 5 Finishing nails
Stain 4 oz 30 Honeycomb Colored
Trimming 3 in 13.85 Celtic Metal Trimming
Wax 5 lb 16.97 To polish finished product
Table 9 contains data for the Materials table. Yellow highlights demonstrate one UnitsOfMeasureID can appear many times.
20
Units of Measure Table
UnitsOfMeasureID Descriptions
bx Box
dz Dozen
ea Each
ft Feet/Foot
in Inch
lb Pounds
oz Ounces
Table 10 contains data for the UnitsOfMeasure table.
Vendor Table
VendorID VendorName Description Address City State ZipCode YTDSales
1 Nail House Screw and Nails 12413 E Harbor Ave Vancouver WA 98685 30
2 Home Depot Miscellaneous 344 W Clark St Portland OR 97203 45.96
3 Design Co. Manufactured 233 E Rick St Aspen CO 81611 520.05
4 Paint Hut
Paint and Paint
Supplies 50012 S Park Rd Portland OR 97202 60
5 Lowes Miscellaneous 987 NW Jestin St Gresham OR 97080 16.97
Table 11 contains data for the Vendors table.
21
Employee Table
EmployeeID Title LastName FirstName PhoneNumber HireDate HourlyWage
1 Supervisor Mullins Greg 5552341243 3/12/05 25
2
Warehouse
Worker Caarp Jessica 5552124566 10/23/10 15
3
Warehouse
Worker Tao Matt 5555641234 1/1/12 13
4
Workshop
Worker Westin Emily 5552144455 3/12/05 20
5
Workshop
Worker Westin Mark 5552145544 3/12/05 20
6 Sales Manager Johnson Abby 5559403431 1/12/06 15
7 Sales Associate Simmons Angus 5556759767 1/17/10 12
8 Inspector Baggins Yogi 5555061254 1/23/06 30
9 Sales Associate Wiggins Ralph 5559861267 2/18/09 12
10 Sales Associate Simpson Marge 5554942223 2/12/06 12
11
Sales Ass.
Manager Arrow Jennifer 6533342340 3/10/10 13
12 Appraiser Wilson Russell 6565442456 6/17/09 45
Table 12 contains data for the Employees table.
22
Sales Invoice Table
SalesInvoiceID EmployeeID CustomerID SalesDate SubTotal Discount ShippingCost TotalDue DeliveryMethodID
2 6 5 2/12/16 600 0.05 0 570 P
3 7 1 4/17/16 120 0 25 145 M
4 7 2 6/19/16 1240 0.08 100 1240.8 D
5 6 3 7/20/16 120 0 25 145 M
7 6 3 8/26/16 1020 0.05 100 1069 D
8 11 9 12/13/14 4000 0.08 100 3780 D
9 9 4 11/23/15 600 0.05 0 570 P
10 10 8 11/17/15 150 0 25 175 M
11 11 1 3/10/15 150 0 25 175 M
12 8 8 2/13/15 1000 0.08 0 920 P
15 8 6 12/24/14 500 0.05 100 575 D
Table 13 contains data for the SalesInvoices table. Yellow highlights demonstrate one EmployeeID and one CustomerID can appear many times. Green highlights show that one
DeliveryMethodID can show up many times.
23
Sales Invoice Details Table
SalesInvoiceDetailsID ProductName SalesInvoiceID Quantity UnitPrice LineTotal
1 Coffee Table 2 1 600 600
2 Lamp 5 1 120 120
3 Night Stand 4 2 620 1240
4 Lamp 3 2 120 240
5 Mirror 7 1 400 400
6 Night Stand_ 7_ 1 610 610
7 Amoire 8 1 4000 4000
8 Desk Chair 9 2 300 600
9 Clock 10 1 150 150
10 Clock 11 1 150 150
11 Coffee Table 15 1 500 500
13
Grandfather
Clock 12 1 1000 1000
Table 14 contains data for the SalesInvoiceDetails table. This table is an intersection table that reconciles a M:M relationship between Products and SalesInvoices. Yellow
highlights demonstrate one ProductName with many SalesInvoiceID. Green highlights show that one SalesInvoiceID can have many ProductName.
Delivery Method Table
DeliveryMethodID Description
D Delivery shipment
M Shipping through US mail
P Pick-up from warehouse
Table 15 contains data for the DeliveryMethods table
24
Customer Table
CustomersID LastName FirstName Address City State ZipCode PhoneNumber YTDPurchases
1 Marsh Sally 432 E Jack St Burlington WA 98564 5556061234 320
2 Dawson Creek 5674 W Worg Rd Portland OR 97022 5554951245 1240.8
3 Boyd Frankie 3945 N HobbitAve Nampa ID 56456 5551235645 1214
4 knight Katie 6785 E AlderranSt Vancouver WA 97048 5554321960 570
5 Konobi Obi-Wan 1233 Tatooine Dr Las Vegas NV 89101 5554443333 570
6 Marley Jacob 1256 ChristmasRd Salem MA 60531 6694332332 575
7 Crachett Bob 4955 TinyTin Ln Annaplolis MD 59643 4953122344 0
8 Cricket Jimmy
1971 Walt Disney
World Orlando FL 32830 4955355931 1095
9 Stark Tony 10880 MalibuPoint Malibu CA 90263 4544122233 3780
Table 16 contains data for the Customers table.
25
Database Script
USE [CityHome02]
GO
/****** Object: Table [dbo].[Customers] Script Date: 12/9/16 1:27:29 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customers](
[CustomersID] [int] IDENTITY(1,1) NOT NULL,
[LastName] [nvarchar](255) NULL,
[FirstName] [nvarchar](255) NULL,
[Address] [nvarchar](255) NULL,
[City] [nvarchar](255) NULL,
[State] [nvarchar](255) NULL,
[ZipCode] [int] NULL,
[PhoneNumber] [bigint] NULL,
[YTDPurchases] [money] NULL,
CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED
(
[CustomersID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DeliveryMethod] Script Date: 12/9/16 1:27:29 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DeliveryMethod](
[DeliveryMethodID] [nvarchar](255) NOT NULL,
[Description] [nvarchar](255) NULL,
CONSTRAINT [PK_DeliveryMethod] PRIMARY KEY CLUSTERED
(
[DeliveryMethodID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Employees] Script Date: 12/9/16 1:27:29 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Employees](
[EmployeeID] [int] IDENTITY(1,1) NOT NULL,
[Title] [nvarchar](50) NULL,
[LastName] [nvarchar](255) NULL,
[FirstName] [nvarchar](255) NULL,
[PhoneNumber] [bigint] NULL,
26
[HireDate] [date] NULL,
[HourlyWage] [money] NULL,
CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED
(
[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Materials] Script Date: 12/9/16 1:27:29 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Materials](
[MaterialNameID] [nvarchar](255) NOT NULL,
[VendorID] [int] NULL,
[UnitOfMeasureID] [nvarchar](255) NULL,
[ListPrice] [money] NULL,
[Description] [nvarchar](255) NULL,
CONSTRAINT [PK_Materials] PRIMARY KEY CLUSTERED
(
[MaterialNameID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[ProductCondtion] Script Date: 12/9/16 1:27:30 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ProductCondtion](
[ProductConditionID] [nvarchar](255) NOT NULL,
[Desription] [nvarchar](255) NULL,
CONSTRAINT [PK_ProductCondtion] PRIMARY KEY CLUSTERED
(
[ProductConditionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Products] Script Date: 12/9/16 1:27:30 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Products](
[ProductNameID] [nvarchar](255) NOT NULL,
[AmountPurchased] [int] NULL,
[PurchasedPrice] [money] NULL,
[ProductConditionID] [nvarchar](255) NULL,
CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED
(
[ProductNameID] ASC
27
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[SalesInvoiceDetails] Script Date: 12/9/16 1:27:30 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SalesInvoiceDetails](
[SalesInvoiceDetailsID] [int] IDENTITY(1,1) NOT NULL,
[ProductNameID] [nvarchar](255) NULL,
[SalesInvoiceID] [int] NULL,
[Quantity] [int] NULL,
[UnitPrice] [money] NULL,
[LineTotal] [money] NULL,
CONSTRAINT [PK_SalesInvoiceDetails] PRIMARY KEY CLUSTERED
(
[SalesInvoiceDetailsID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[SalesInvoices] Script Date: 12/9/16 1:27:30 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SalesInvoices](
[SalesInvoiceID] [int] IDENTITY(1,1) NOT NULL,
[EmployeeID] [int] NULL,
[CustomerID] [int] NULL,
[SalesDate] [date] NULL,
[SubTotal] [money] NULL,
[Discount] [decimal](18, 2) NULL,
[ShippingCost] [money] NULL,
[TotalDue] [money] NULL,
[DeliveryMethodID] [nvarchar](255) NULL,
CONSTRAINT [PK_SalesInvoice] PRIMARY KEY CLUSTERED
(
[SalesInvoiceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[UnitOfMeasure] Script Date: 12/9/16 1:27:30 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[UnitOfMeasure](
[UnitsOfMeasureID] [nvarchar](255) NOT NULL,
[Descriptions] [nvarchar](255) NULL,
CONSTRAINT [PK_UnitOfMaterials] PRIMARY KEY CLUSTERED
28
(
[UnitsOfMeasureID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Vendors] Script Date: 12/9/16 1:27:30 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Vendors](
[VendorID] [int] IDENTITY(1,1) NOT NULL,
[VendorName] [nvarchar](255) NULL,
[Description] [nvarchar](255) NULL,
[Address] [nvarchar](255) NULL,
[City] [nvarchar](255) NULL,
[State] [nvarchar](255) NULL,
[ZipCode] [int] NULL,
[YTDSales] [money] NULL,
CONSTRAINT [PK_Vendor] PRIMARY KEY CLUSTERED
(
[VendorID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[WorkOrderLabor] Script Date: 12/9/16 1:27:30 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WorkOrderLabor](
[WorkOrderLaborID] [int] IDENTITY(1,1) NOT NULL,
[EmployeeID] [int] NULL,
[WorkOrderID] [int] NULL,
[WorkDate] [date] NULL,
[Hours] [nchar](10) NULL,
[EmployeeCost] [money] NULL,
CONSTRAINT [PK_LaborCosts] PRIMARY KEY CLUSTERED
(
[WorkOrderLaborID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[WorkOrderMaterials] Script Date: 12/9/16 1:27:30 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WorkOrderMaterials](
[WorkOrderMaterialsID] [int] IDENTITY(1,1) NOT NULL,
[WorkOrderID] [int] NULL,
29
[OrderDate] [date] NULL,
[MaterialNameID] [nvarchar](255) NULL,
[UnitPrice] [money] NULL,
[OrderQty] [int] NULL,
[TotalPrice] [money] NULL,
CONSTRAINT [PK_WorkOrderDetails] PRIMARY KEY CLUSTERED
(
[WorkOrderMaterialsID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[WorkOrders] Script Date: 12/9/16 1:27:30 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WorkOrders](
[WorkOrderID] [int] IDENTITY(1,1) NOT NULL,
[ProductNameID] [nvarchar](255) NULL,
[WorkOrderDate] [date] NULL,
[TotalEmployeeCost] [money] NULL,
[TotalMaterialCost] [money] NULL,
[TotalRepairCost] [money] NULL,
CONSTRAINT [PK_Work Order] PRIMARY KEY CLUSTERED
(
[WorkOrderID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[Customers] ON
GO
INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City],
[State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (1, N'Marsh', N'Sally', N'432 E
Jack St', N'Burlington', N'WA', 98564, 5556061234, 320.0000)
GO
INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City],
[State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (2, N'Dawson', N'Creek', N'5674
W Worg Rd', N'Portland', N'OR', 97022, 5554951245, 1240.8000)
GO
INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City],
[State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (3, N'Boyd', N'Frankie', N'
3945 N Hobbit Ave', N'Nampa', N'ID', 56456, 5551235645, 1214.0000)
GO
INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City],
[State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (4, N'knight', N'Katie', N'6785
E Alderran St', N'Vancouver', N'WA', 97048, 5554321960, 570.0000)
GO
INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City],
[State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (5, N'Konobi', N'Obi-Wan',
N'1233 Tatooine Dr', N'Las Vegas', N'NV', 89101, 5554443333, 570.0000)
GO
30
INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City],
[State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (6, N'Marley', N'Jacob', N'1256
Christmas Rd ', N'Salem', N'MA', 60531, 6694332332, 575.0000)
GO
INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City],
[State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (7, N'Crachett', N'Bob', N'4955
Tiny Tin Ln', N'Annaplolis', N'MD', 59643, 4953122344, 0.0000)
GO
INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City],
[State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (8, N'Cricket', N'Jimmy',
N'1971 Walt Disney World', N'Orlando', N'FL', 32830, 4955355931, 1095.0000)
GO
INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City],
[State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (9, N'Stark', N'Tony', N'10880
Malibu Point', N'Malibu', N'CA', 90263, 4544122233, 3780.0000)
GO
SET IDENTITY_INSERT [dbo].[Customers] OFF
GO
INSERT [dbo].[DeliveryMethod] ([DeliveryMethodID], [Description]) VALUES (N'D',
N'Delivery shipment')
GO
INSERT [dbo].[DeliveryMethod] ([DeliveryMethodID], [Description]) VALUES (N'M',
N'Shipping through US mail')
GO
INSERT [dbo].[DeliveryMethod] ([DeliveryMethodID], [Description]) VALUES (N'P', N'Pick-up
from warehouse')
GO
SET IDENTITY_INSERT [dbo].[Employees] ON
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (1, N'Supervisor', N'Mullins', N'Greg', 5552341243,
CAST(N'2005-03-12' AS Date), 25.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (2, N'Warehouse Worker', N'Caarp', N'Jessica',
5552124566, CAST(N'2010-10-23' AS Date), 15.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (3, N'Warehouse Worker', N'Tao', N'Matt', 5555641234,
CAST(N'2012-01-01' AS Date), 13.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (4, N'Workshop Worker', N'Westin', N'Emily', 5552144455,
CAST(N'2005-03-12' AS Date), 20.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (5, N'Workshop Worker', N'Westin', N'Mark', 5552145544,
CAST(N'2005-03-12' AS Date), 20.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (6, N'Sales Manager', N'Johnson', N'Abby', 5559403431,
CAST(N'2006-01-12' AS Date), 15.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (7, N'Sales Associate', N'Simmons', N'Angus',
5556759767, CAST(N'2010-01-17' AS Date), 12.0000)
GO
31
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (8, N'Inspector', N'Baggins', N'Yogi', 5555061254,
CAST(N'2006-01-23' AS Date), 30.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (9, N'Sales Associate', N'Wiggins', N'Ralph',
5559861267, CAST(N'2009-02-18' AS Date), 12.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (10, N'Sales Associate', N'Simpson', N'Marge',
5554942223, CAST(N'2006-02-12' AS Date), 12.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (11, N'Sales Ass. Manager', N'Arrow', N'Jennifer',
6533342340, CAST(N'2010-03-10' AS Date), 13.0000)
GO
INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber],
[HireDate], [HourlyWage]) VALUES (12, N'Appraiser', N'Wilson', N'Russell', 6565442456,
CAST(N'2009-06-17' AS Date), 45.0000)
GO
SET IDENTITY_INSERT [dbo].[Employees] OFF
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Bolts', 2, N'ea', 1.9900, N'3 inch Bolts')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Cable', 5, N'Ft', 1.3400, N'14 gauge ')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Crews', 1, N'bx', 12.9900, N'One inch')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Hinge', 3, N'ea', 90.0000, N'Special three-way hinge')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Mirror', 3, N'ea', 250.0000, N'Star shaped')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Nails', 1, N'bx', 10.0000, N'Ten Penny')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Nuts', 2, N'ea', 0.4500, N'Match 3 inch Bolts')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Paint', 4, N'oz', 15.0000, N'Egg shell white')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Sand Paper', 2, N'ea', 8.9900, N'Extra Fine')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Small Nails', 1, N'dz', 5.0000, N'Finishing nails')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Stain', 4, N'oz', 30.0000, N'Honeycomb Colored')
GO
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Trimming', 3, N'in', 13.8500, N'Celtic Metal Trimming')
GO
32
INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice],
[Description]) VALUES (N'Wax', 5, N'lb', 16.9700, N'To polish finished product')
GO
INSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'PRT',
N'Product used for parts')
GO
INSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'RF',
N'Product needs to be repared befor Sale')
GO
INSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'RP',
N'Product is turned into new product')
GO
INSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'S',
N'Product is ready for sale')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Amoire', 1, 70.0000, N'S')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Bookshelve', 2, 80.0000, N'RP')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Broken Couch', 1, 0.0000, N'PRT')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Broken Desk', 1, 0.0000, N'PRT')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'China Hutch', 1, 100.0000, N'RP')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Clock', 2, 8.0000, N'S')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Coffee Table', 1, 50.0000, N'S')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Couch', 1, 100.0000, N'RF')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Desk', 2, 30.0000, N'RF')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Desk Chair', 2, 25.0000, N'S')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Dressor', 1, 53.0000, N'S')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Grandfather Clock', 1, 45.0000, N'S')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Lamp', 3, 45.0000, N'S')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Latern', 1, 12.0000, N'RF')
GO
33
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Mirror', 1, 40.0000, N'S')
GO
INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice],
[ProductConditionID]) VALUES (N'Night Stand', 3, 100.0000, N'S')
GO
SET IDENTITY_INSERT [dbo].[SalesInvoiceDetails] ON
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (1, N'Coffee Table', 2, 1,
600.0000, 600.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (2, N'Lamp', 5, 1,
120.0000, 120.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (3, N'Night Stand', 4, 2,
620.0000, 1240.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (4, N'Lamp', 3, 2,
120.0000, 240.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (5, N'Mirror', 7, 1,
400.0000, 400.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (6, N'Night Stand', 7, 1,
610.0000, 610.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (7, N'Amoire', 8, 1,
4000.0000, 4000.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (8, N'Desk Chair', 9, 2,
300.0000, 600.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (9, N'Clock', 10, 1,
150.0000, 150.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (10, N'Clock', 11, 1,
150.0000, 150.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (11, N'Coffee Table', 15,
1, 500.0000, 500.0000)
GO
INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID],
[SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (13, N'Grandfather Clock',
12, 1, 1000.0000, 1000.0000)
GO
SET IDENTITY_INSERT [dbo].[SalesInvoiceDetails] OFF
34
GO
SET IDENTITY_INSERT [dbo].[SalesInvoices] ON
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (2, 6, 5,
CAST(N'2016-02-12' AS Date), 600.0000, CAST(0.05 AS Decimal(18, 2)), 0.0000, 570.0000,
N'P')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (3, 7, 1,
CAST(N'2016-04-17' AS Date), 120.0000, CAST(0.00 AS Decimal(18, 2)), 25.0000, 145.0000,
N'M')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (4, 7, 2,
CAST(N'2016-06-19' AS Date), 1240.0000, CAST(0.08 AS Decimal(18, 2)), 100.0000,
1240.8000, N'D')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (5, 6, 3,
CAST(N'2016-07-20' AS Date), 120.0000, CAST(0.00 AS Decimal(18, 2)), 25.0000, 145.0000,
N'M')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (7, 6, 3,
CAST(N'2016-08-26' AS Date), 1020.0000, CAST(0.05 AS Decimal(18, 2)), 100.0000,
1069.0000, N'D')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (8, 11, 9,
CAST(N'2014-12-13' AS Date), 4000.0000, CAST(0.08 AS Decimal(18, 2)), 100.0000,
3780.0000, N'D')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (9, 9, 4,
CAST(N'2015-11-23' AS Date), 600.0000, CAST(0.05 AS Decimal(18, 2)), 0.0000, 570.0000,
N'P')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (10, 10,
8, CAST(N'2015-11-17' AS Date), 150.0000, CAST(0.00 AS Decimal(18, 2)), 25.0000,
175.0000, N'M')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (11, 11,
1, CAST(N'2015-03-10' AS Date), 150.0000, CAST(0.00 AS Decimal(18, 2)), 25.0000,
175.0000, N'M')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (12, 8, 8,
CAST(N'2015-02-13' AS Date), 1000.0000, CAST(0.08 AS Decimal(18, 2)), 0.0000, 920.0000,
N'P')
GO
INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate],
[SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (15, 8, 6,
CAST(N'2014-12-24' AS Date), 500.0000, CAST(0.05 AS Decimal(18, 2)), 100.0000, 575.0000,
N'D')
35
GO
SET IDENTITY_INSERT [dbo].[SalesInvoices] OFF
GO
INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'bx', N'Box')
GO
INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'dz',
N'Dozen')
GO
INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'ea', N'Each')
GO
INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'ft',
N'Feet/Foot')
GO
INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'in', N'Inch')
GO
INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'lb',
N'Pounds')
GO
INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'oz',
N'Ounces')
GO
SET IDENTITY_INSERT [dbo].[Vendors] ON
GO
INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City],
[State], [ZipCode], [YTDSales]) VALUES (1, N'Nail House', N'Screw and Nails', N'12413 E
Harbor Ave', N'Vancouver', N'WA', 98685, 30.0000)
GO
INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City],
[State], [ZipCode], [YTDSales]) VALUES (2, N'Home Depot', N'Miscellaneous', N'344 W Clark
St', N'Portland', N'OR', 97203, 45.9600)
GO
INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City],
[State], [ZipCode], [YTDSales]) VALUES (3, N'Design Co.', N'Manufactured', N'233 E Rick
St', N'Aspen', N'CO', 81611, 520.0500)
GO
INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City],
[State], [ZipCode], [YTDSales]) VALUES (4, N'Paint Hut', N'Paint and Paint Supplies',
N'50012 S Park Rd', N'Portland', N'OR', 97202, 60.0000)
GO
INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City],
[State], [ZipCode], [YTDSales]) VALUES (5, N'Lowes', N'Miscellaneous', N'987 NW Jestin
St', N'Gresham', N'OR', 97080, 16.9700)
GO
SET IDENTITY_INSERT [dbo].[Vendors] OFF
GO
SET IDENTITY_INSERT [dbo].[WorkOrderLabor] ON
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (1, 8, 1, CAST(N'2016-01-01' AS Date), N'1
', 30.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (2, 5, 1, CAST(N'2016-01-03' AS Date), N'4
', 80.0000)
GO
36
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (3, 1, 1, CAST(N'2016-01-03' AS Date), N'2
', 50.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (4, 4, 1, CAST(N'2016-01-12' AS Date), N'2
', 40.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (5, 12, 1, CAST(N'2016-01-25' AS Date), N'1
', 45.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (6, 8, 2, CAST(N'2016-06-14' AS Date), N'1
', 30.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (7, 4, 2, CAST(N'2016-06-22' AS Date), N'3
', 39.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (8, 1, 2, CAST(N'2016-07-09' AS Date), N'2
', 50.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (9, 12, 2, CAST(N'2016-07-20' AS Date), N'1
', 45.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (10, 4, 3, CAST(N'2016-08-16' AS Date), N'2
', 40.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (11, 8, 4, CAST(N'2016-08-20' AS Date), N'1
', 40.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (12, 5, 4, CAST(N'2016-09-30' AS Date), N'4
', 80.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (13, 8, 5, CAST(N'2016-09-14' AS Date), N'1
', 30.0000)
GO
INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID],
[WorkDate], [Hours], [EmployeeCost]) VALUES (14, 12, 5, CAST(N'2016-09-20' AS Date), N'1
', 45.0000)
GO
SET IDENTITY_INSERT [dbo].[WorkOrderLabor] OFF
GO
SET IDENTITY_INSERT [dbo].[WorkOrderMaterials] ON
GO
INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate],
[MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (1, 1, CAST(N'2016-01-03'
AS Date), N'Stain', 30.0000, 2, 60.0000)
GO
37
INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate],
[MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (2, 2, CAST(N'2016-06-22'
AS Date), N'Nails', 10.0000, 2, 20.0000)
GO
INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate],
[MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (3, 2, CAST(N'2016-06-23'
AS Date), N'Mirror', 250.0000, 1, 250.0000)
GO
INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate],
[MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (4, 1, CAST(N'2016-01-12'
AS Date), N'Wax', 16.9700, 1, 16.9700)
GO
INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate],
[MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (5, 3, CAST(N'2016-08-10'
AS Date), N'Sand Paper', 8.9900, 4, 35.9600)
GO
INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate],
[MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (6, 4, CAST(N'2016-08-22'
AS Date), N'Trimming', 13.8500, 13, 180.0500)
GO
INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate],
[MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (7, 1, CAST(N'2016-01-20'
AS Date), N'Hinge', 90.0000, 1, 90.0000)
GO
INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate],
[MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (8, 2, CAST(N'2016-06-30'
AS Date), N'Small Nails', 5.0000, 2, 10.0000)
GO
INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate],
[MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (9, 3, CAST(N'2016-08-12'
AS Date), N'Nails', 10.0000, 1, 10.0000)
GO
SET IDENTITY_INSERT [dbo].[WorkOrderMaterials] OFF
GO
SET IDENTITY_INSERT [dbo].[WorkOrders] ON
GO
INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate],
[TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (1, N'Desk',
CAST(N'2016-01-01' AS Date), 200.0000, 166.9700, 360.9700)
GO
INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate],
[TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (2, N'Bookshelve',
CAST(N'2016-06-14' AS Date), 240.0000, 280.0000, 520.0000)
GO
INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate],
[TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (3, N'Broken Desk',
CAST(N'2016-08-16' AS Date), 40.0000, 45.9600, 85.9600)
GO
INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate],
[TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (4, N'Desk',
CAST(N'2016-08-20' AS Date), 100.0000, 180.0500, 280.0500)
GO
INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate],
[TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (5, N'Coffee Table',
CAST(N'2016-09-14' AS Date), 75.0000, 0.0000, 75.0000)
GO
SET IDENTITY_INSERT [dbo].[WorkOrders] OFF
38
GO
ALTER TABLE [dbo].[Materials] WITH CHECK ADD CONSTRAINT [FK_Materials_UnitOfMaterials]
FOREIGN KEY([UnitOfMeasureID])
REFERENCES [dbo].[UnitOfMeasure] ([UnitsOfMeasureID])
GO
ALTER TABLE [dbo].[Materials] CHECK CONSTRAINT [FK_Materials_UnitOfMaterials]
GO
ALTER TABLE [dbo].[Materials] WITH CHECK ADD CONSTRAINT [FK_Materials_Vendor] FOREIGN
KEY([VendorID])
REFERENCES [dbo].[Vendors] ([VendorID])
GO
ALTER TABLE [dbo].[Materials] CHECK CONSTRAINT [FK_Materials_Vendor]
GO
ALTER TABLE [dbo].[Products] WITH CHECK ADD CONSTRAINT [FK_Product_ProductCondtion]
FOREIGN KEY([ProductConditionID])
REFERENCES [dbo].[ProductCondtion] ([ProductConditionID])
GO
ALTER TABLE [dbo].[Products] CHECK CONSTRAINT [FK_Product_ProductCondtion]
GO
ALTER TABLE [dbo].[SalesInvoiceDetails] WITH CHECK ADD CONSTRAINT
[FK_SalesInvoiceDetails_Products] FOREIGN KEY([ProductNameID])
REFERENCES [dbo].[Products] ([ProductNameID])
GO
ALTER TABLE [dbo].[SalesInvoiceDetails] CHECK CONSTRAINT
[FK_SalesInvoiceDetails_Products]
GO
ALTER TABLE [dbo].[SalesInvoiceDetails] WITH CHECK ADD CONSTRAINT
[FK_SalesInvoiceDetails_SalesInvoice] FOREIGN KEY([SalesInvoiceID])
REFERENCES [dbo].[SalesInvoices] ([SalesInvoiceID])
GO
ALTER TABLE [dbo].[SalesInvoiceDetails] CHECK CONSTRAINT
[FK_SalesInvoiceDetails_SalesInvoice]
GO
ALTER TABLE [dbo].[SalesInvoices] WITH CHECK ADD CONSTRAINT [FK_SalesInvoice_Customers]
FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomersID])
GO
ALTER TABLE [dbo].[SalesInvoices] CHECK CONSTRAINT [FK_SalesInvoice_Customers]
GO
ALTER TABLE [dbo].[SalesInvoices] WITH CHECK ADD CONSTRAINT
[FK_SalesInvoice_DeliveryMethod] FOREIGN KEY([DeliveryMethodID])
REFERENCES [dbo].[DeliveryMethod] ([DeliveryMethodID])
GO
ALTER TABLE [dbo].[SalesInvoices] CHECK CONSTRAINT [FK_SalesInvoice_DeliveryMethod]
GO
ALTER TABLE [dbo].[SalesInvoices] WITH CHECK ADD CONSTRAINT [FK_SalesInvoice_Employee]
FOREIGN KEY([EmployeeID])
REFERENCES [dbo].[Employees] ([EmployeeID])
GO
ALTER TABLE [dbo].[SalesInvoices] CHECK CONSTRAINT [FK_SalesInvoice_Employee]
GO
ALTER TABLE [dbo].[WorkOrderLabor] WITH CHECK ADD CONSTRAINT [FK_LaborCosts_Employees]
FOREIGN KEY([EmployeeID])
REFERENCES [dbo].[Employees] ([EmployeeID])
GO
ALTER TABLE [dbo].[WorkOrderLabor] CHECK CONSTRAINT [FK_LaborCosts_Employees]
GO
39
ALTER TABLE [dbo].[WorkOrderLabor] WITH CHECK ADD CONSTRAINT [FK_LaborCosts_WorkOrders]
FOREIGN KEY([WorkOrderID])
REFERENCES [dbo].[WorkOrders] ([WorkOrderID])
GO
ALTER TABLE [dbo].[WorkOrderLabor] CHECK CONSTRAINT [FK_LaborCosts_WorkOrders]
GO
ALTER TABLE [dbo].[WorkOrderMaterials] WITH CHECK ADD CONSTRAINT
[FK_WorkOrderDetails_WorkOrder] FOREIGN KEY([WorkOrderID])
REFERENCES [dbo].[WorkOrders] ([WorkOrderID])
GO
ALTER TABLE [dbo].[WorkOrderMaterials] CHECK CONSTRAINT [FK_WorkOrderDetails_WorkOrder]
GO
ALTER TABLE [dbo].[WorkOrderMaterials] WITH CHECK ADD CONSTRAINT
[FK_WorkOrderMaterials_Materials1] FOREIGN KEY([MaterialNameID])
REFERENCES [dbo].[Materials] ([MaterialNameID])
GO
ALTER TABLE [dbo].[WorkOrderMaterials] CHECK CONSTRAINT
[FK_WorkOrderMaterials_Materials1]
GO
ALTER TABLE [dbo].[WorkOrders] WITH CHECK ADD CONSTRAINT [FK_WorkOrders_Products]
FOREIGN KEY([ProductNameID])
REFERENCES [dbo].[Products] ([ProductNameID])
GO
ALTER TABLE [dbo].[WorkOrders] CHECK CONSTRAINT [FK_WorkOrders_Products]
GO

Contenu connexe

En vedette

Professional Library Literature
Professional Library LiteratureProfessional Library Literature
Professional Library Literature
46144
 
Calculo de diferenciales
Calculo de diferencialesCalculo de diferenciales
Calculo de diferenciales
190416
 
Izibongo zamakhosi zithathwa_njengencwadi_yomlomo_yomlando_wamakhosi_kanye_no...
Izibongo zamakhosi zithathwa_njengencwadi_yomlomo_yomlando_wamakhosi_kanye_no...Izibongo zamakhosi zithathwa_njengencwadi_yomlomo_yomlando_wamakhosi_kanye_no...
Izibongo zamakhosi zithathwa_njengencwadi_yomlomo_yomlando_wamakhosi_kanye_no...
Simphiwe Sandile Ndlovu
 

En vedette (19)

Professional Library Literature
Professional Library LiteratureProfessional Library Literature
Professional Library Literature
 
Calculo de diferenciales
Calculo de diferencialesCalculo de diferenciales
Calculo de diferenciales
 
A Review on a Database Encryption Paper
A Review on a Database Encryption PaperA Review on a Database Encryption Paper
A Review on a Database Encryption Paper
 
Fundamental of information technology
Fundamental of information technologyFundamental of information technology
Fundamental of information technology
 
Presentacion Gestion Talento Humano
Presentacion Gestion Talento HumanoPresentacion Gestion Talento Humano
Presentacion Gestion Talento Humano
 
Meeting
MeetingMeeting
Meeting
 
Izibongo zamakhosi zithathwa_njengencwadi_yomlomo_yomlando_wamakhosi_kanye_no...
Izibongo zamakhosi zithathwa_njengencwadi_yomlomo_yomlando_wamakhosi_kanye_no...Izibongo zamakhosi zithathwa_njengencwadi_yomlomo_yomlando_wamakhosi_kanye_no...
Izibongo zamakhosi zithathwa_njengencwadi_yomlomo_yomlando_wamakhosi_kanye_no...
 
Importancia de la ti en las organizaciones
Importancia de la ti en las organizacionesImportancia de la ti en las organizaciones
Importancia de la ti en las organizaciones
 
TARJETAS CRC
TARJETAS CRCTARJETAS CRC
TARJETAS CRC
 
Open by default: the challenges of research data in Europe
Open by default: the challenges of research data in EuropeOpen by default: the challenges of research data in Europe
Open by default: the challenges of research data in Europe
 
Searching for Candidates On Google: A Primer
Searching for Candidates On Google: A Primer Searching for Candidates On Google: A Primer
Searching for Candidates On Google: A Primer
 
Teaching the next generation of Information Literacy educators: pedagogy and ...
Teaching the next generation of Information Literacy educators: pedagogy and ...Teaching the next generation of Information Literacy educators: pedagogy and ...
Teaching the next generation of Information Literacy educators: pedagogy and ...
 
operator overloading
operator overloadingoperator overloading
operator overloading
 
Expose de l ascenseur
Expose de l ascenseurExpose de l ascenseur
Expose de l ascenseur
 
CivicsNZ – Civics, Citizenship and Curriculum
CivicsNZ – Civics, Citizenship and CurriculumCivicsNZ – Civics, Citizenship and Curriculum
CivicsNZ – Civics, Citizenship and Curriculum
 
Pengantar Akuntansi 2 - Ch14 Financial Statement Analysis
Pengantar Akuntansi 2 - Ch14 Financial Statement Analysis Pengantar Akuntansi 2 - Ch14 Financial Statement Analysis
Pengantar Akuntansi 2 - Ch14 Financial Statement Analysis
 
Media and Information Literacy (MIL) 2. The Evolution of Traditional to New M...
Media and Information Literacy (MIL) 2. The Evolution of Traditional to New M...Media and Information Literacy (MIL) 2. The Evolution of Traditional to New M...
Media and Information Literacy (MIL) 2. The Evolution of Traditional to New M...
 
MCA Industrial visit
MCA Industrial visitMCA Industrial visit
MCA Industrial visit
 
An efficient approach for load balancing using dynamic ab algorithm in cloud ...
An efficient approach for load balancing using dynamic ab algorithm in cloud ...An efficient approach for load balancing using dynamic ab algorithm in cloud ...
An efficient approach for load balancing using dynamic ab algorithm in cloud ...
 

Similaire à City Home Database Design

Jiri_Ptacek_Blackbelt_Case_study_Certified
Jiri_Ptacek_Blackbelt_Case_study_CertifiedJiri_Ptacek_Blackbelt_Case_study_Certified
Jiri_Ptacek_Blackbelt_Case_study_Certified
Jiri Ptacek
 
spillar resume submit 9-15-16
spillar resume submit 9-15-16spillar resume submit 9-15-16
spillar resume submit 9-15-16
Benjamin Spillar
 
LO16-1 through LO16-5EXERCISE 16.1Accounting TerminologyLi.docx
LO16-1 through LO16-5EXERCISE 16.1Accounting TerminologyLi.docxLO16-1 through LO16-5EXERCISE 16.1Accounting TerminologyLi.docx
LO16-1 through LO16-5EXERCISE 16.1Accounting TerminologyLi.docx
SHIVA101531
 
Material Management
Material ManagementMaterial Management
Material Management
S. M Zabed
 
Corinne Mayhew CV 2016
Corinne Mayhew CV 2016Corinne Mayhew CV 2016
Corinne Mayhew CV 2016
Corinne Mayhew
 

Similaire à City Home Database Design (20)

Managerial Accounting 2 Acco.396
Managerial Accounting 2 Acco.396Managerial Accounting 2 Acco.396
Managerial Accounting 2 Acco.396
 
ACCOUNTING FOR MATERIAL.pptx
ACCOUNTING FOR MATERIAL.pptxACCOUNTING FOR MATERIAL.pptx
ACCOUNTING FOR MATERIAL.pptx
 
Prototype and test v final
Prototype and test v finalPrototype and test v final
Prototype and test v final
 
Industrial training report / Summer Vacation Report / Institutional Training ...
Industrial training report / Summer Vacation Report / Institutional Training ...Industrial training report / Summer Vacation Report / Institutional Training ...
Industrial training report / Summer Vacation Report / Institutional Training ...
 
4. job order cost systems
4. job order cost systems4. job order cost systems
4. job order cost systems
 
CH 01 Cost of Manaufactured.pptx
CH 01 Cost of Manaufactured.pptxCH 01 Cost of Manaufactured.pptx
CH 01 Cost of Manaufactured.pptx
 
Jiri_Ptacek_Blackbelt_Case_study_Certified
Jiri_Ptacek_Blackbelt_Case_study_CertifiedJiri_Ptacek_Blackbelt_Case_study_Certified
Jiri_Ptacek_Blackbelt_Case_study_Certified
 
Sapmmint 131118092016-phpapp02
Sapmmint 131118092016-phpapp02Sapmmint 131118092016-phpapp02
Sapmmint 131118092016-phpapp02
 
Salient Features of Computerized Accounting
Salient Features of Computerized AccountingSalient Features of Computerized Accounting
Salient Features of Computerized Accounting
 
cost accounting ppt.pptx
cost accounting  ppt.pptxcost accounting  ppt.pptx
cost accounting ppt.pptx
 
SAP MM Interview questions
SAP MM Interview questionsSAP MM Interview questions
SAP MM Interview questions
 
Acc 349 Preview Full Course
Acc 349 Preview Full Course Acc 349 Preview Full Course
Acc 349 Preview Full Course
 
spillar resume submit 9-15-16
spillar resume submit 9-15-16spillar resume submit 9-15-16
spillar resume submit 9-15-16
 
Myshop2014 Tech Report
Myshop2014 Tech Report Myshop2014 Tech Report
Myshop2014 Tech Report
 
LO16-1 through LO16-5EXERCISE 16.1Accounting TerminologyLi.docx
LO16-1 through LO16-5EXERCISE 16.1Accounting TerminologyLi.docxLO16-1 through LO16-5EXERCISE 16.1Accounting TerminologyLi.docx
LO16-1 through LO16-5EXERCISE 16.1Accounting TerminologyLi.docx
 
Material Management
Material ManagementMaterial Management
Material Management
 
Inventory IAS
Inventory IASInventory IAS
Inventory IAS
 
VALUE CREATION
VALUE CREATIONVALUE CREATION
VALUE CREATION
 
C++ super market
C++ super marketC++ super market
C++ super market
 
Corinne Mayhew CV 2016
Corinne Mayhew CV 2016Corinne Mayhew CV 2016
Corinne Mayhew CV 2016
 

City Home Database Design

  • 1. City Home Cover Page Team Members: Nadine Miller Chris Morgan Yuri Voronyuk MIS 372 December 10th, 2016
  • 2. ii Executive Summary City Home is a privately owned vintage, antique and industrial furniture business that buys and sells reclaimed furniture. City Home originally did not have an automated system to keep track of their work shop and sales process. City Home was recording everything manually in Excel which was very time-consuming and did not allow for much analysis. The operational database documented here is designed to support the entire work shop and sales process for the products at City Home. By keeping track of the initial purchase price of each product, the cost of materials and services required to repurpose or refurbish the product, and the sale price, City Home can ensure they are generating profit. The key processes which generate and store data in the database include inspecting the product, assigning a work order, setting a price and generating a sales invoice. In addition, materials can be ordered for the workshop. To effectively capture data from these processes a normalized data schema includes a table for products, customers, employees, materials, vendors, the recording of the work order transactions and the sales invoice transactions, among many others. The key goal for City Home’s operational database was to effectively keep track of profits in a timely and efficient manner. To eliminate data redundancy and prevent anomalies, the database uses primary and foreign keys. In addition, referential integrity is enforced with relationships connecting all the tables to each other – as depicted in the database diagram. In order to support efficient management and ensure the company is generating profit effectively, two reports are developed. The first report is the work order report which includes details about a particular product. The report includes the purchase price, the employee labor cost(s) and materials cost to generate a total cost of repurposing and refurbishing the item. The second report is the sales staff activity report which includes sales information about each sales employee. The report includes the employee’s first name, total sales, average sales and the number of sales. The report also generates a total to keep track of sales between a particular date range. In such a fast paced environment the need for an operational database was necessary. City Home will now be able to keep track of their data more effectively and efficiently and ensure that they are maintaining their ultimate goal – to preserve the history and reduce a carbon profit all while running a profitable business.
  • 3. iii Tabl eof Contents Table of Contents CITY HOME COVER PAGE I EXECUTIVE SUMMARY II TABLE OF CONTENTS III REVISIONS AND REPORTS 1 NARRATIVE 1 ORGANIZATIONAL OVERVIEW: 1 PROCESS OVERVIEW: 1 DETAILED PROCESS DESCRIPTION: 2 ENTER NEW PRODUCT: 2 SEND TO INSPECTION: 2 SEND WORK ORDER TO WORKSHOP AND FULFILL WORK ORDER: 2 CREATE QR CODE: 3 SET PRICE: 3 PRINT QR CODE AND CREATE PRODUCT SHOWCASE: 3 SELL PRODUCT: 3 BUSINESS PROCESS END 3 LIST OF TRANSACTIONS AND OBJECTS WITH ATTRIBUTES: 4 OBJECTS: 4 TRANSACTIONS: 4 FLOW CHARTS 5 CITY HOME BUSINESS PROCESS 5 CITY HOME INSPECTION SUB PROCESS 6 CITY HOME WORK ORDER SUB PROCESS 7 CITY HOME SALES SUB PROCESS 8 ENTITY-RELATIONSHIP (E-R) DIAGRAM 9 E-R DIAGRAM FOR CITY HOME 9 CARDINALITY CONSTRAINTS: 9 DATA TYPES: 10 DATA DIAGRAM 11 CITY HOME DATABASE SCHEMA: 11 DESIGN EXPLANATION 12 OBJECT TABLES 12 TRANSACTION TABLES 12 EXAMPLES OF CALCULATED DATA 12 PRJ2 WORK ORDER REPORT 12 REPORT DOCUMENTATION: 12 WORK ORDER REPORT 13
  • 4. iv SQL QUERIES 13 REPORT HEADER 13 FIRST PART OF REPORT 14 SECOND PART OF REPORT BODY 14 PRJ3 SALES STAFF ACTIVITY REPORT 15 REPORT DOCUMENTATION: 15 REPORT PROCEDURE 15 SQL STORED PROCEDURE QUERIES 16 SALES STAFF ACTIVITY REPORT 16 UPDATED PRJ2 EXAMPLE DATA 17 DATABASE SCRIPT 25
  • 5. 1 Revisions and Reports Narrative Organizational Overview: City Home is a privately owned vintage, antique and industrial furniture business that buys and sells reclaimed furniture. Located in the heart of downtown Portland, City Home buys used furniture from local antique stores, flea markets, garage sales, estate sales and private parties. City Home consists of two warehouses, a workshop and a store front. All furniture is purchased locally in the Portland area and placed in the store for resale. However, before being placed for sale in the store, most products undergo some kind of change. Nearly 80% of the products need to be refurbished or repurposed. City Home originally had no way to record their business process so it was difficult to determine which products generated the most profit. City Home will now be more efficient and be able to track costs as they pertain to each product. It also holds all employees accountable for the work they are doing, whether it is inspecting the product, working on the product, or selling the product. City Home buys nearly 300 unique pieces of furniture each month and sells approximately 8 a day. Profit is generated by purchasing products at a very low price, improving or changing the product using materials and services, and selling the product for more than the adjusted basis and the work done to it. Some products are even immediately marked up and ready for resale. The main goal at City Home is to make profit but also promote the use of salvaged and reclaimed materials in order to preserve the history of such products and to reduce a carbon footprint. Process Overview: City Home’s product as-is, refurbish, repurpose and resale process involves the product, an employee, a workshop employee and possibly an appraiser. The primary purpose of the process is to record initial details about each product that enters the warehouse and the process it undergoes before it is ready for resale. While some products do not need any work and are immediatelyplacedinthe store, most products need to be repairedor repurposed. Thisis decided by our professional inspectors who inspect each product carefully before deciding what needs to be done to it. The inspection employee then creates a work order. The product is later sent to our workshop where our workers spend hours carefully refurbishing or repurposing each product whilestill keeping the original productsintegrityandunique style. Thisinspection process is usually completed within a day and the workshop process within a week. An appraiser will be contacted in order to help determine a price if it cannot be determined by the workshop. QR codes are created to track product in warehouse. QR codes make it easy to track product movements and gives locations. Due to limited space in the store and the size of most products, they cannot be displayed in store. Customer can scan the code to access more photos of the product and a detailed description of the Product. Once the product is ready for sale and a price has been assigned a showcase is built to give customers a small preview of the product and
  • 6. 2 a place to Scan the QR Code. Customer may check out with a sales associate or with their smart phones. Invoice is sent to appropriate warehouse to alert warehouse employees to prep product. Once Product is picked up by customer or shipped to customer the full process has been completed. Detailed Process Description: City Home recently adopted a new automated process to keep track of when a product enters the warehouse for the first time and what is done to it in order for it to be placed for sale in the store. This process not only tracks important information about each individual product, but also the costs associated with getting the product ready for sale in order to find profit. Enter New Product: New product enters the City Home warehouse. The product is catalogued.A product id is assigned to the product. The product type, condition and purchase price are also recorded. Product informationis sent to the Data Store. The maingoal of recording this initial informationisto record purchase price in order to later determine profit after the product has been worked on and sold. After the product has entered the warehouse and been catalogued, it is sent to inspection. Send to Inspection: Once the product has been sent to inspection, the inspection employees carefully look at the product and decide whether or not the product is immediately ready for resale – meaning nothing needs to be changed, only a price needs to be assigned – or if the product needs to be refurbished or repurposed. If it is ready for resale, an inspector sets the price, has the QR code created, and the product information is sent to the sales department. If the product needs to be refurbished or repurposed, it is recorded on the work order and the work order is sent to the workshop with the product. Work Orders are sent to the Data Store. Send Work Order to Workshop and Fulfill Work Order: Work order is sent to the workshop. A workshop employee will observe the product and the work order and decide what materials and services are needed to refurbish or repurpose the product. Workshop employee decides what materialsareneededto work on the product. Materialsinclude but are not limited to nails, bolts, tools, sandpaper, paint, replacement pieces, fabric, etc. Cost of materials is recorded. If a certain material is unavailable it is ordered. Workshop employee also records services done to the product. Services include but are not limited to sanding, painting, carpentry work, etc. Hours of work is also recorded with the hourly wage to keep track of how much is going in to the repurpose or refurbish process of the product.
  • 7. 3 Create QR Code: After the work order isfulfilled,a QR is created.A QR Code is specific to each product. The purpose of the QR code is to track the product after it has been refurbished or repurposed and as it goes through the appraisal and sales process. Set Price: After the completion of the work order, a price must be assigned. However, the workshop decides whether or not the product needs to be appraised. If the product does not need to be appraised, the workshop determines a price for the product. If the product needs to be professionally appraised, say for historical purposes, or if the product has been entirely turned into a new type of product, a professional appraiser is outsourced and comes to the workshop to giveanappraisal. The workshop assigns a pricebased on the appraisal.Once a price has been assigned each product in the Data Store now includes not only the purchase price but also the sale price. The QR code is then updated to include the price for customer viewing. Print QR Code and Create Product Showcase: The QR code for each product must be printed so that customers can scan the product if they wish. For each product a showcase is created in the store for customers to see pictures, description, and scan a QR code of the product. Sell Product: Once a customer chooses a particular product for purchase and its delivery type (a pick-up from the Warehouse or shipping to home address), they scan the QR code using an app on their Smartphone to launch checkout. If the customer is new to the store, the system adds their information to the Customers table in the DataStore. If the customer already exists in the DataStore, their information is used to generate a new invoice. Invoices exist in a DataStore as a separate table. After the invoice is generated, customer makes a payment. After the sale is finalized, customer receives an e-receipt via e-mail. The invoice is then sent to Warehouse, where the product is prepared either for the pick-up or shipment, depending on the customer’s preference. When the product is prepared for a pick-up, the customer may come and receive it any time during working hours. When the product is shipped out, the customer should expect to receive it in 6-10 business days. Business Process End The business process ends when the product has been sold. The whole purpose of this process is to record every stage the product undergoes and the cost associated with doing so in order to generate profit. Purchase price, cost of materials used, and hours of services done (hourly wage x hours worked) and sale price will determine the profit.
  • 8. 4 List of Transactions and Objects with Attributes: Objects: Product is a person, place or thing so it is an object. Products are the most important object in this process. The products have several attributes that rarely change. A product list is maintained including product, product type, product condition and product cost. Employee is a person, so it is an object. An employee list is maintained including employee name and position. Position is included to specify whether the employee is an inspection employee, workshop employee or sales employee. Customer is a person, so it is an object. A customer list is maintained including customer name, email and phone number. Customers purchase the products. Material is a thing, so it is an object. A material list is maintained including material cost, description and vendor. Materials are ordered to be used to fulfill work orders. Transactions: The work order, which is created by an inspection employee in order to determine what the workshop will do to the product, is a transaction. City Home wants to track the attributes for each work order and every work order is different because every piece of furniture (the product) received is different and needs a different kind of work. Work order includes the inspection employee who created the work order, the product being worked on, work order date, whether the product needs to be refurbished or repurposed, total material cost, hours worked, and completion date. These details are recorded once, on a single work order, for a single product. Once the work order is complete, the data does not need to be changed. It is complete and at that point the product is complete. The invoice, which is created by a sales employee in order for a customer to purchase a product, is a transaction. City Home wants to track the attributes for each invoice, and every invoice is different because of every product purchased is different and every customer that makes a purchase is different. Invoice includes the customer who is making the purchase, the sales employee creating the invoice, the product(s) being purchases, delivery type, and price. The detailsof the invoice arerecordedonce, on a singleinvoice,for a singlecustomer.Once the invoice is complete and the sale has been made, the data does not need to be changed. It is complete. The material order, which is created by an employee in order to purchase materials needed to work on the products is a transaction. City Home wants to keep track of costs associated with refurbishing and repurposing an item, therefore there must be a way to record costs of materials used. The materials order includes
  • 9. 5 Flow Charts City Home Business Process CITY HOME BUSINESS PROCESS Data StoreWarehouse Inspection Workshop Appraiser Sales Acquire New Product Catalog Product Send To Inspection Complete Inspection Send Work Order To Workshop Fulfill Work Order Send to Appraiser Set Price Need Appraisal Workshop Sets Price Appraise Product Update Price In QR Code Print QR Code Create Product Showcase Create QR Code Invoices Products Work Orders Products Products Sell Product Figure 1 shows the main City Homebusiness process. It tracks the Product from the time it enters the warehouseuntil the product is sold. The purpose of this process is to track costs associated with the product and the final sale price in order to determine the profit made. City Homeoriginally did not have any kind of automated process to record inspection of the product or work done to each product.
  • 10. 6 City Home Inspection Sub Process City Home Inspection Sub Process Data StoreWorkshopWarehouse Employee Inspect Product Create Work Order Send Product To Workshop Needs Work Done Work Orders Receive Product Products Product Ready For Sale Set Sale Price Request Inspection Store Product Figure 2 shows the inspection sub-process. The inspection process tracks the product from the time it enters inspection until the time it is sent to the workshop with a work order. Note: If the product does notneed to be refurbished or repurposed it is immediately ready for resale, an inspection employee sets the price and the product is sent back to the warehouse.
  • 11. 7 City Home Work Order Sub Process City Home Fulfill Work Order Sub Process WorkshopWarehouse Vendors Data Store Send Product to Workshop Receive Product Access Work Order Order Materials Repair Product Need Materials Materials Available Send Materials Work Orders Create QR Code Complete Work Order Return Product Warehouse Accept Product Products Work Orders Products Record Services and Hourly Wage Figure 3 shows the sub process of fulfilling the work order. Within the sub-process materials may be order, QR codes created for finished products, and products is returned to warehouse. Employees also track there hours worked to repair or refurbish the product.
  • 12. 8 City Home Sales Sub Process City Home Sales Sub Process CustomerSales Warehouse Data Store Create Product Showcase Scan QR Code Checkout Add Customer Create Invoice Pay Invoice Finalize Sale Receive Invoice Ship ProductReceive Product Prepare Product for Pick-up Products Customers Invoices Pick-up Produuct e-receipt Existing Customer New Customer Products Ship Product Figure 4 shows the sales sub-process. The sales process tracks the product from the time it is showcased until the time it is purchased by and shipped to customer.
  • 13. 9 Entity-Relationship(E-R) Diagram E-R Diagram for City home Figure 5 is the entity-relationship diagram for City Home. It includes four objects and two transactions. Objects include employee, item, customer, and material. Transactions include work order and invoice. Cardinality Constraints:  Each employee has a unique id, title, first and last name, phone number, hire date and hourly wage.  Eachproduct has a unique id(product name),product condition id,amount purchased and purchased price.  Each customer has a unique id, first and last name, address, and phone number.  Each material has a unique id, vendor id, unit of measure id, list price and description.  Each inspection employee can inspect one or many items. However, employee represents several positions – inspection employee, workshop employee and sales employee. Each sales employee can create one or many invoices. Each workshop employee can fulfill one or many work orders.  Each product can be inspected by one or many inspection employee. Each product can be assigned to one work order. Each product can be purchased by one customer and multiple customers can purchase multiple products.  Each customer can buy one or many products and a customer can be assigned to one or many invoices.  Each material can be ordered to fulfill one or many work orders, but one work order may or may not need materials.
  • 14. 10 Data Types:  Employee (object) data used to record details of the employee o EmployeeID – integer, unique identifier [primary key] o Title – text o Last name, first name – text o PhoneNumber – integer o HireDate – date o HourlyWage – decimal  Work order (transaction) data used to record details of the work order o WorkOrderID – integer, unique identifier [primary key] o EmployeeID – integer [foreign key] o ProductID – integer [foreign key] o WorkOrderDate – date o EmployeeHours – decimal o EmployeeCost – money o TotalMaterialCost – money o TotalCost – money  Product (object) data used to record details of the item o ProductName – text, unique identifier [primary key] o ProductConditionID – integer [foreign key] o AmountPurchased – integer o PurchasedPrice – money  Invoice (transaction) data is used to record details of the invoice o SalesInvoiceID – integer, unique identifier [primary key] o CustomerID – integer, unique identifier [foreign key] o EmployeeID – integer, unique identifier [foreign key] o SalesDate – date o SubTotal – money o Discount – integer o ShippingCost – money o TotalDue – money o DeliveryMethodID – integer [foreign key]  Customer (object) data is used to record details of the customer o CustomerID – integer, unique identifier [primary key] o LastName – text o FirstName – text o Address – text o City – text
  • 15. 11 o State – text o ZipCode – integer o PhoneNumber – integer o YTDPurchased – money  Material (object) data is used to record details of the material o MaterialsID– text, unique identifier [primary key] o VendorID – integer [foreign key] o UnitOfMeasureID – integer [foreign key] o ListPrice – money o Description – text Data Diagram City Home Database Schema: Figure 6 is the database diagram for City Home’s work order and sales process.
  • 16. 12 Design Explanation Object Tables: Products, Employees, Materials, Customers and Vendors are object tables because they are people or things that are involved in many transactions or events. Transaction Tables: WorkOrder is a transaction table because it records the event of assigning a work order to a product, working on the product, and costs associated with working on the product. SalesInvoice is a transaction table because it records sales events. Examples of Calculated Data: YTDSales in the Vendors table is calculated as the sum of all sales from each vendor for the year and YTDPurchases in the Customers table is calculated as the sum of all purchases made by each customer for the year. Other calculated data includes LineTotal in the InvoiceDetailstable, TotalDue in the SalesInvoices table, TotalCost in the WorkOrders table and TotalPrice in WorkOrderDetails. PRJ2Work Order Report Report Documentation: The work order report is created in order to track details about work done to a specific product using certain materials. The purpose of the work order is to primarily record costs associated with refurbishing or repurposing a product. Work order details areimportantbecause it specifieswhich materials were used to work on the product and at what cost. The work order is basically the focal point of CityHome’s workshop process and necessary indetermining profit and loss after the sales process. The final work order report can be generated once the product is inspected, assigned a work order, the work order is sent to the workshop, and materials are ordered and used to work on and recreate the final product – so basically the product must have undergone the entire workshop process before the report serves a purpose. More specifically on our flow chart, data included in the report isa result of the following:“Inspect Product,” “Assigna Work Order,” “Fulfill Work Order.” The product must be assigned a condition – either ready for sale, needs to be repurposed, or needs to be refurbished. If the product needs to be refurbished or repurposed, it has been assigned a work order and sent to the work shop for the work order to be fulfilled. The work order is fulfilled by including employee hours and materials needed. At City Home, an inspector will review all the work orders before the price is officially assigned to the product to ensure that everything was done correctly and to ensure that City Home is actually
  • 17. 13 making profit on the products they refurbish or repurpose. The report contains two sections: a report header and a report body. The report header contains information about a given work order, such as the work order ID, product ID, employee ID, work order date, employee hours, total material cost, and total cost. The report body displays details of the work order such as which materials were ordered, quantity of materials ordered, unit price, and total price. Work Order Report City Home - Work Order Report Work Order #: 1 Date: 1/1/2016 Product Name: Desk Product Purchase Price: $30.00 Total Work Order Cost: $411.97 Employee Information Name Title Hourly Wage Hours Cost Work Date Yogi Baggins Inspector $30.00 1 $30.00 1/1/2016 Mark Westin Workshop Worker $20.00 4 $80.00 1/3/2016 Greg Mullins Supervisor $25.00 2 $50.00 1/3/2016 Emily Westin Workshop Worker $20.00 2 $40.00 1/12/2016 Russell Wilson Appraiser $45.00 1 $45.00 1/25/2016 Material Information Material Name Order Quantity Unit of Meas. UnitPrice Total Price Order Date Stain 2 oz $30 $60.00 1/3/2016 Wax 1 lb $16.97 $16.97 1/12/2016 Hinge 1 ea $90.00 $90.00 1/20/2016 Figure 7 shows the details for a specific work order – work order number 1. SQL Queries Report Header “Work Order Header” Query SELECT TOP (100) PERCENT dbo.WorkOrders.WorkOrderID AS [Work Order #], dbo.WorkOrders.WorkOrderDate AS [Work Order Date], dbo.Products.ProductName AS [Product Name], dbo.WorkOrders.TotalRepairCost AS [Total Repair Cost] FROM dbo.WorkOrders INNER JOIN dbo.Products ON dbo.WorkOrders.ProductName = dbo.Products.ProductName WHERE (dbo.WorkOrders.WorkOrderID = 1)
  • 18. 14 Work Order # Work Order Date Product Name Total Repair Cost 1 1/1/16 Desk 360.97 Table 1displays the information required for the heading of the work order report. First Part of Report “Work Order Materials” Query SELECT TOP (100) PERCENT dbo.WorkOrderMaterials.OrderDate AS [Order Date], dbo.Materials.MaterialName AS [Material Name], dbo.WorkOrderMaterials.OrderQty AS [Order Quantity], dbo.Materials.UnitOfMeasureID AS [Unit Of Meas.], dbo.WorkOrderMaterials.UnitPrice AS [Unit Price], dbo.WorkOrderMaterials.TotalPrice AS [Total Price] FROM dbo.WorkOrderMaterials INNER JOIN dbo.Materials ON dbo.WorkOrderMaterials.MaterialName = dbo.Materials.MaterialName WHERE (dbo.WorkOrderMaterials.WorkOrderID = 1) ORDER BY [Order Date] Material Name Order Date Order Quantity Unit Of Meas. Unit Price Total Price Stain 1/3/16 2 oz 30 60 Wax 1/12/16 1 lb 16.97 16.97 Hinge 1/20/16 1 ea 90 90 Table 2 displays the information required for the second part of the work order report body – the material information. Second Part of Report Body “Work Order Labor” Query SELECT TOP (100) PERCENT dbo.Employees.Title, dbo.Employees.LastName AS [Last Name], dbo.Employees.FirstName AS [First Name], dbo.WorkOrderLabor.WorkDate AS [Work Date], dbo.WorkOrderLabor.Hours, dbo.Employees.HourlyWage AS [Hourly Wage], dbo.WorkOrderLabor.EmployeeCost AS [Employee Cost] FROM dbo.Employees INNER JOIN dbo.WorkOrderLabor ON dbo.Employees.EmployeeID = dbo.WorkOrderLabor.EmployeeID WHERE (dbo.WorkOrderLabor.WorkOrderID = 1) ORDER BY [Work Date]
  • 19. 15 Title Last Name First Name Work Date Hourly Wage Hours Employee Cost Inspector Baggins Yogi 1/1/16 30 1 30 Workshop Worker Westin Mark 1/3/16 20 4 80 Supervisor Mullins Greg 1/3/16 25 2 50 Workshop Worker Westin Emily 1/12/16 20 2 40 Appraiser Wilson Russell 1/25/16 45 1 45 Table 3 displays the information required for the third part of the work order report body – the employee information. PRJ3Sales Staff Activity Report Report Documentation: The sales staff activity report is generated in order for us to see how many sales each employee makes in a given period. The report consists of two parts and contains an employee’s first name, dollar amount of total and average sales, the number of sales by an employee in a given period, and the total amount of allsales and its total dollar amount. The report is important to City Home as the shop strives to generate as many sales as possible. Employees with the greatest generated revenue are encouraged to mentor their fellow co-workers by sharing stories of successful sales. This report is also valuable in terms of determining which employees might deserve a bonus or a raise at the end of the year, or should be more motivated. Lastly, knowing the total amount of sales is crucial in understanding where City Home is standing financiallyand what possiblechanges should be made in order to meet its financialgoals.Because the report can be generated for a particular period, it is easy for City Home to see how sales activity changes from one period to another, which is important when planning a budget, or simply for the record keeping purposes. This particular report is focusing on the last two years of City Home’s operations and lists six employees and their sales statistics. Understanding where the company stands financially is key to having a successful business. Report Procedure “To Date Sales” Query USE [CityHome02] --Shows the database we are using GO CREATEPROCEDURE [dbo].[SalesWithTotalsPRJ] --Name of the stored procedure (--Input parameters are a date range @startDateasDateTime, @endDateasDateTime ) AS--Main body of the report SELECTTOP (100)PERCENTdbo.Employees.FirstName, SUM(dbo.SalesInvoices.SubTotal)AS [Total Sales],--aggregation by the sum AVG(dbo.SalesInvoices.SubTotal)AS [Average Sales],--aggregation by the average
  • 20. 16 COUNT(dbo.SalesInvoices.SalesInvoiceID)AS [Number of Sales] --aggregation by count FROMdbo.EmployeesINNERJOINdbo.SalesInvoices ONdbo.Employees.EmployeeID=dbo.SalesInvoices.EmployeeID WHERE (dbo.SalesInvoices.SalesDate>=CONVERT(DATETIME, @startDate, 102))--filter for the start date AND(dbo.SalesInvoices.SalesDate<=CONVERT(DATETIME, @endDate, 102))--filter for the end date GROUPBYdbo.Employees.FirstName--Aggregator for grouping ORDERBYSUM(dbo.SalesInvoices.SubTotal)DESC--result set by descending order --The totals table SELECTTOP (100)PERCENT SUM(SubTotal)AS [Total Sales],--aggregation by the sum AVG(SubTotal)AS [Average Sales],--aggregation by the average COUNT(SalesInvoiceID)AS [Number of Sales] --aggregation by the count FROMdbo.SalesInvoices WHERE (SalesDate>=CONVERT(DATETIME, @startDate, 102))--filter for the start date AND(SalesDate<=CONVERT(DATETIME, @endDate, 102))--filter by the end date ORDERBYSUM(SubTotal)--result set by descending order SQL Stored Procedure Queries This query generates two result sets: the report body and the totals table. It uses date range as an input parameter in order for the user to specify the period for which the report is generated. This is done by the WHERE filter parameter. The query uses SUM aggregator to produce total sales by an employee, AVG aggregator to produce average sales dollar amount set, and COUNT to show the number of invoices a particular employee has made in that period. The query also uses GROUP BY to aggregate sales data by employee, and organizes the order of the result set with ORDER BY, in this case the SUM, or total sales, in descending order. The full query is presented below. Sales Staff Activity Report City Home - Sales Staff Activity Report From 1/1/2014 to 12/31/2016 First Name Total Sales Average Sales Number of Sales Jennifer $4,150.00 $2,075.00 2 Abby $1,740.00 $580.00 3 Yogi $1,500.00 $750.00 2 Angus $1,360.00 $680.00 2 Ralph $600.00 $600.00 1 Marge $150.00 $150.00 1 Total: $9,500.00 $863.64 11 Figure 8 show the sales staff activity report for City Home for the data 1/1/2014 to 12/31/2016.
  • 21. 17 Updated PRJ2Example Data Product Name Table ProductName AmountPurchased PurchasedPrice ProductConditionID Armoire 1 70 S Bookshelf 2 80 RP Broken Couch 1 0 PRT Broken Desk 1 0 PRT China Hutch 1 100 RP Clock 2 8 S Coffee Table 1 50 S Couch 1 100 RF Desk 2 30 RF Desk Chair 2 25 S Dresser 1 53 S Grandfather Clock 1 45 S Lamp 3 45 S Lantern 1 12 RF Mirror 1 40 S Night Stand 3 100 S Table 4 contains data for the Products table. Yellow highlights show that one ProductConditionID can appear many times. Product Condition Table ProductConditionID Desription PRT Product used for parts RF Product needs to be repaired before Sale RP Product is turned into new product S Product is ready for sale Table 5 contains data for the ProductCondition table.
  • 22. 18 Work Order Labor Table WorkOrderLaborID EmployeeID WorkOrderID WorkDate Hours EmployeeCost 1 8 1 1/1/16 1 30 2 5 1 1/3/16 4 80 3 1 1 1/3/16 2 50 4 4 1 1/12/16 2 40 5 12 1 1/25/16 1 45 6 8 2 6/14/16 1 30 7 4 2 6/22/16 3 39 8 1 2 7/9/16 2 50 9 12 2 7/20/16 1 45 10 4 3 8/16/16 2 40 11 8 4 8/20/16 1 40 12 5 4 9/30/16 4 80 13 8 5 9/14/16 1 30 14 12 5 9/20/16 1 45 Table 6 13 contains data for the WorkOrderLabor table. Work Order Table WorkOrderID ProductName WorkOrderDate TotalEmployeeCost TotalMaterialCost TotalRepairCost 1 Desk 1/1/16 200 166.97 360.97 2 Bookshelf 6/14/16 240 280 520 3 Broken Desk 8/16/16 40 45.96 85.96 4 Desk 8/20/16 100 180.05 280.05 5 Coffee Table 9/14/16 75 0 75 Table 7 contains data for the WordOrder table. Yellow highlights demonstrate that one ProductName and one EmployeeID can appear many times.
  • 23. 19 Work Order Materials Table WorkOrderMaterialsID WorkOrderID OrderDate MaterialName UnitPrice OrderQty TotalPrice 1 1 1/3/16 Stain 30 2 60 2 2 6/22/16 Nails 10 2 20 3 2 6/23/16 Mirror 250 1 250 4 1 1/12/16 Wax 16.97 1 16.97 5 3 8/10/16 Sand Paper 8.99 4 35.96 6 4 8/22/16 Trimming 13.85 13 180.05 7 1 1/20/16 Hinge 90 1 90 8 2 6/30/16 Small Nails 5 2 10 9 3 8/12/16 Nails 10 1 10 Table 8 contains data for the WorkOrderMaterials table. Materials Table MaterialName VendorID UnitOfMeasureID ListPrice Description Bolts 2 ea 1.99 3 inch Bolts Cable 5 Ft 1.34 14 gauge Crews 1 bx 12.99 One inch Hinge 3 ea 90 Special three-way hinge Mirror 3 ea 250 Star shaped Nails 1 bx 10 Ten Penny Nuts 2 ea 0.45 Match 3 inch Bolts Paint 4 oz 15 Egg shell white Sand Paper 2 ea 8.99 Extra Fine Small Nails 1 dz 5 Finishing nails Stain 4 oz 30 Honeycomb Colored Trimming 3 in 13.85 Celtic Metal Trimming Wax 5 lb 16.97 To polish finished product Table 9 contains data for the Materials table. Yellow highlights demonstrate one UnitsOfMeasureID can appear many times.
  • 24. 20 Units of Measure Table UnitsOfMeasureID Descriptions bx Box dz Dozen ea Each ft Feet/Foot in Inch lb Pounds oz Ounces Table 10 contains data for the UnitsOfMeasure table. Vendor Table VendorID VendorName Description Address City State ZipCode YTDSales 1 Nail House Screw and Nails 12413 E Harbor Ave Vancouver WA 98685 30 2 Home Depot Miscellaneous 344 W Clark St Portland OR 97203 45.96 3 Design Co. Manufactured 233 E Rick St Aspen CO 81611 520.05 4 Paint Hut Paint and Paint Supplies 50012 S Park Rd Portland OR 97202 60 5 Lowes Miscellaneous 987 NW Jestin St Gresham OR 97080 16.97 Table 11 contains data for the Vendors table.
  • 25. 21 Employee Table EmployeeID Title LastName FirstName PhoneNumber HireDate HourlyWage 1 Supervisor Mullins Greg 5552341243 3/12/05 25 2 Warehouse Worker Caarp Jessica 5552124566 10/23/10 15 3 Warehouse Worker Tao Matt 5555641234 1/1/12 13 4 Workshop Worker Westin Emily 5552144455 3/12/05 20 5 Workshop Worker Westin Mark 5552145544 3/12/05 20 6 Sales Manager Johnson Abby 5559403431 1/12/06 15 7 Sales Associate Simmons Angus 5556759767 1/17/10 12 8 Inspector Baggins Yogi 5555061254 1/23/06 30 9 Sales Associate Wiggins Ralph 5559861267 2/18/09 12 10 Sales Associate Simpson Marge 5554942223 2/12/06 12 11 Sales Ass. Manager Arrow Jennifer 6533342340 3/10/10 13 12 Appraiser Wilson Russell 6565442456 6/17/09 45 Table 12 contains data for the Employees table.
  • 26. 22 Sales Invoice Table SalesInvoiceID EmployeeID CustomerID SalesDate SubTotal Discount ShippingCost TotalDue DeliveryMethodID 2 6 5 2/12/16 600 0.05 0 570 P 3 7 1 4/17/16 120 0 25 145 M 4 7 2 6/19/16 1240 0.08 100 1240.8 D 5 6 3 7/20/16 120 0 25 145 M 7 6 3 8/26/16 1020 0.05 100 1069 D 8 11 9 12/13/14 4000 0.08 100 3780 D 9 9 4 11/23/15 600 0.05 0 570 P 10 10 8 11/17/15 150 0 25 175 M 11 11 1 3/10/15 150 0 25 175 M 12 8 8 2/13/15 1000 0.08 0 920 P 15 8 6 12/24/14 500 0.05 100 575 D Table 13 contains data for the SalesInvoices table. Yellow highlights demonstrate one EmployeeID and one CustomerID can appear many times. Green highlights show that one DeliveryMethodID can show up many times.
  • 27. 23 Sales Invoice Details Table SalesInvoiceDetailsID ProductName SalesInvoiceID Quantity UnitPrice LineTotal 1 Coffee Table 2 1 600 600 2 Lamp 5 1 120 120 3 Night Stand 4 2 620 1240 4 Lamp 3 2 120 240 5 Mirror 7 1 400 400 6 Night Stand_ 7_ 1 610 610 7 Amoire 8 1 4000 4000 8 Desk Chair 9 2 300 600 9 Clock 10 1 150 150 10 Clock 11 1 150 150 11 Coffee Table 15 1 500 500 13 Grandfather Clock 12 1 1000 1000 Table 14 contains data for the SalesInvoiceDetails table. This table is an intersection table that reconciles a M:M relationship between Products and SalesInvoices. Yellow highlights demonstrate one ProductName with many SalesInvoiceID. Green highlights show that one SalesInvoiceID can have many ProductName. Delivery Method Table DeliveryMethodID Description D Delivery shipment M Shipping through US mail P Pick-up from warehouse Table 15 contains data for the DeliveryMethods table
  • 28. 24 Customer Table CustomersID LastName FirstName Address City State ZipCode PhoneNumber YTDPurchases 1 Marsh Sally 432 E Jack St Burlington WA 98564 5556061234 320 2 Dawson Creek 5674 W Worg Rd Portland OR 97022 5554951245 1240.8 3 Boyd Frankie 3945 N HobbitAve Nampa ID 56456 5551235645 1214 4 knight Katie 6785 E AlderranSt Vancouver WA 97048 5554321960 570 5 Konobi Obi-Wan 1233 Tatooine Dr Las Vegas NV 89101 5554443333 570 6 Marley Jacob 1256 ChristmasRd Salem MA 60531 6694332332 575 7 Crachett Bob 4955 TinyTin Ln Annaplolis MD 59643 4953122344 0 8 Cricket Jimmy 1971 Walt Disney World Orlando FL 32830 4955355931 1095 9 Stark Tony 10880 MalibuPoint Malibu CA 90263 4544122233 3780 Table 16 contains data for the Customers table.
  • 29. 25 Database Script USE [CityHome02] GO /****** Object: Table [dbo].[Customers] Script Date: 12/9/16 1:27:29 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Customers]( [CustomersID] [int] IDENTITY(1,1) NOT NULL, [LastName] [nvarchar](255) NULL, [FirstName] [nvarchar](255) NULL, [Address] [nvarchar](255) NULL, [City] [nvarchar](255) NULL, [State] [nvarchar](255) NULL, [ZipCode] [int] NULL, [PhoneNumber] [bigint] NULL, [YTDPurchases] [money] NULL, CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED ( [CustomersID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[DeliveryMethod] Script Date: 12/9/16 1:27:29 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[DeliveryMethod]( [DeliveryMethodID] [nvarchar](255) NOT NULL, [Description] [nvarchar](255) NULL, CONSTRAINT [PK_DeliveryMethod] PRIMARY KEY CLUSTERED ( [DeliveryMethodID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Employees] Script Date: 12/9/16 1:27:29 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Employees]( [EmployeeID] [int] IDENTITY(1,1) NOT NULL, [Title] [nvarchar](50) NULL, [LastName] [nvarchar](255) NULL, [FirstName] [nvarchar](255) NULL, [PhoneNumber] [bigint] NULL,
  • 30. 26 [HireDate] [date] NULL, [HourlyWage] [money] NULL, CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED ( [EmployeeID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Materials] Script Date: 12/9/16 1:27:29 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Materials]( [MaterialNameID] [nvarchar](255) NOT NULL, [VendorID] [int] NULL, [UnitOfMeasureID] [nvarchar](255) NULL, [ListPrice] [money] NULL, [Description] [nvarchar](255) NULL, CONSTRAINT [PK_Materials] PRIMARY KEY CLUSTERED ( [MaterialNameID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[ProductCondtion] Script Date: 12/9/16 1:27:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[ProductCondtion]( [ProductConditionID] [nvarchar](255) NOT NULL, [Desription] [nvarchar](255) NULL, CONSTRAINT [PK_ProductCondtion] PRIMARY KEY CLUSTERED ( [ProductConditionID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Products] Script Date: 12/9/16 1:27:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Products]( [ProductNameID] [nvarchar](255) NOT NULL, [AmountPurchased] [int] NULL, [PurchasedPrice] [money] NULL, [ProductConditionID] [nvarchar](255) NULL, CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED ( [ProductNameID] ASC
  • 31. 27 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[SalesInvoiceDetails] Script Date: 12/9/16 1:27:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[SalesInvoiceDetails]( [SalesInvoiceDetailsID] [int] IDENTITY(1,1) NOT NULL, [ProductNameID] [nvarchar](255) NULL, [SalesInvoiceID] [int] NULL, [Quantity] [int] NULL, [UnitPrice] [money] NULL, [LineTotal] [money] NULL, CONSTRAINT [PK_SalesInvoiceDetails] PRIMARY KEY CLUSTERED ( [SalesInvoiceDetailsID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[SalesInvoices] Script Date: 12/9/16 1:27:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[SalesInvoices]( [SalesInvoiceID] [int] IDENTITY(1,1) NOT NULL, [EmployeeID] [int] NULL, [CustomerID] [int] NULL, [SalesDate] [date] NULL, [SubTotal] [money] NULL, [Discount] [decimal](18, 2) NULL, [ShippingCost] [money] NULL, [TotalDue] [money] NULL, [DeliveryMethodID] [nvarchar](255) NULL, CONSTRAINT [PK_SalesInvoice] PRIMARY KEY CLUSTERED ( [SalesInvoiceID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[UnitOfMeasure] Script Date: 12/9/16 1:27:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[UnitOfMeasure]( [UnitsOfMeasureID] [nvarchar](255) NOT NULL, [Descriptions] [nvarchar](255) NULL, CONSTRAINT [PK_UnitOfMaterials] PRIMARY KEY CLUSTERED
  • 32. 28 ( [UnitsOfMeasureID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Vendors] Script Date: 12/9/16 1:27:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Vendors]( [VendorID] [int] IDENTITY(1,1) NOT NULL, [VendorName] [nvarchar](255) NULL, [Description] [nvarchar](255) NULL, [Address] [nvarchar](255) NULL, [City] [nvarchar](255) NULL, [State] [nvarchar](255) NULL, [ZipCode] [int] NULL, [YTDSales] [money] NULL, CONSTRAINT [PK_Vendor] PRIMARY KEY CLUSTERED ( [VendorID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[WorkOrderLabor] Script Date: 12/9/16 1:27:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[WorkOrderLabor]( [WorkOrderLaborID] [int] IDENTITY(1,1) NOT NULL, [EmployeeID] [int] NULL, [WorkOrderID] [int] NULL, [WorkDate] [date] NULL, [Hours] [nchar](10) NULL, [EmployeeCost] [money] NULL, CONSTRAINT [PK_LaborCosts] PRIMARY KEY CLUSTERED ( [WorkOrderLaborID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[WorkOrderMaterials] Script Date: 12/9/16 1:27:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[WorkOrderMaterials]( [WorkOrderMaterialsID] [int] IDENTITY(1,1) NOT NULL, [WorkOrderID] [int] NULL,
  • 33. 29 [OrderDate] [date] NULL, [MaterialNameID] [nvarchar](255) NULL, [UnitPrice] [money] NULL, [OrderQty] [int] NULL, [TotalPrice] [money] NULL, CONSTRAINT [PK_WorkOrderDetails] PRIMARY KEY CLUSTERED ( [WorkOrderMaterialsID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[WorkOrders] Script Date: 12/9/16 1:27:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[WorkOrders]( [WorkOrderID] [int] IDENTITY(1,1) NOT NULL, [ProductNameID] [nvarchar](255) NULL, [WorkOrderDate] [date] NULL, [TotalEmployeeCost] [money] NULL, [TotalMaterialCost] [money] NULL, [TotalRepairCost] [money] NULL, CONSTRAINT [PK_Work Order] PRIMARY KEY CLUSTERED ( [WorkOrderID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET IDENTITY_INSERT [dbo].[Customers] ON GO INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (1, N'Marsh', N'Sally', N'432 E Jack St', N'Burlington', N'WA', 98564, 5556061234, 320.0000) GO INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (2, N'Dawson', N'Creek', N'5674 W Worg Rd', N'Portland', N'OR', 97022, 5554951245, 1240.8000) GO INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (3, N'Boyd', N'Frankie', N' 3945 N Hobbit Ave', N'Nampa', N'ID', 56456, 5551235645, 1214.0000) GO INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (4, N'knight', N'Katie', N'6785 E Alderran St', N'Vancouver', N'WA', 97048, 5554321960, 570.0000) GO INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (5, N'Konobi', N'Obi-Wan', N'1233 Tatooine Dr', N'Las Vegas', N'NV', 89101, 5554443333, 570.0000) GO
  • 34. 30 INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (6, N'Marley', N'Jacob', N'1256 Christmas Rd ', N'Salem', N'MA', 60531, 6694332332, 575.0000) GO INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (7, N'Crachett', N'Bob', N'4955 Tiny Tin Ln', N'Annaplolis', N'MD', 59643, 4953122344, 0.0000) GO INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (8, N'Cricket', N'Jimmy', N'1971 Walt Disney World', N'Orlando', N'FL', 32830, 4955355931, 1095.0000) GO INSERT [dbo].[Customers] ([CustomersID], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber], [YTDPurchases]) VALUES (9, N'Stark', N'Tony', N'10880 Malibu Point', N'Malibu', N'CA', 90263, 4544122233, 3780.0000) GO SET IDENTITY_INSERT [dbo].[Customers] OFF GO INSERT [dbo].[DeliveryMethod] ([DeliveryMethodID], [Description]) VALUES (N'D', N'Delivery shipment') GO INSERT [dbo].[DeliveryMethod] ([DeliveryMethodID], [Description]) VALUES (N'M', N'Shipping through US mail') GO INSERT [dbo].[DeliveryMethod] ([DeliveryMethodID], [Description]) VALUES (N'P', N'Pick-up from warehouse') GO SET IDENTITY_INSERT [dbo].[Employees] ON GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (1, N'Supervisor', N'Mullins', N'Greg', 5552341243, CAST(N'2005-03-12' AS Date), 25.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (2, N'Warehouse Worker', N'Caarp', N'Jessica', 5552124566, CAST(N'2010-10-23' AS Date), 15.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (3, N'Warehouse Worker', N'Tao', N'Matt', 5555641234, CAST(N'2012-01-01' AS Date), 13.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (4, N'Workshop Worker', N'Westin', N'Emily', 5552144455, CAST(N'2005-03-12' AS Date), 20.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (5, N'Workshop Worker', N'Westin', N'Mark', 5552145544, CAST(N'2005-03-12' AS Date), 20.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (6, N'Sales Manager', N'Johnson', N'Abby', 5559403431, CAST(N'2006-01-12' AS Date), 15.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (7, N'Sales Associate', N'Simmons', N'Angus', 5556759767, CAST(N'2010-01-17' AS Date), 12.0000) GO
  • 35. 31 INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (8, N'Inspector', N'Baggins', N'Yogi', 5555061254, CAST(N'2006-01-23' AS Date), 30.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (9, N'Sales Associate', N'Wiggins', N'Ralph', 5559861267, CAST(N'2009-02-18' AS Date), 12.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (10, N'Sales Associate', N'Simpson', N'Marge', 5554942223, CAST(N'2006-02-12' AS Date), 12.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (11, N'Sales Ass. Manager', N'Arrow', N'Jennifer', 6533342340, CAST(N'2010-03-10' AS Date), 13.0000) GO INSERT [dbo].[Employees] ([EmployeeID], [Title], [LastName], [FirstName], [PhoneNumber], [HireDate], [HourlyWage]) VALUES (12, N'Appraiser', N'Wilson', N'Russell', 6565442456, CAST(N'2009-06-17' AS Date), 45.0000) GO SET IDENTITY_INSERT [dbo].[Employees] OFF GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Bolts', 2, N'ea', 1.9900, N'3 inch Bolts') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Cable', 5, N'Ft', 1.3400, N'14 gauge ') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Crews', 1, N'bx', 12.9900, N'One inch') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Hinge', 3, N'ea', 90.0000, N'Special three-way hinge') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Mirror', 3, N'ea', 250.0000, N'Star shaped') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Nails', 1, N'bx', 10.0000, N'Ten Penny') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Nuts', 2, N'ea', 0.4500, N'Match 3 inch Bolts') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Paint', 4, N'oz', 15.0000, N'Egg shell white') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Sand Paper', 2, N'ea', 8.9900, N'Extra Fine') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Small Nails', 1, N'dz', 5.0000, N'Finishing nails') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Stain', 4, N'oz', 30.0000, N'Honeycomb Colored') GO INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Trimming', 3, N'in', 13.8500, N'Celtic Metal Trimming') GO
  • 36. 32 INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Wax', 5, N'lb', 16.9700, N'To polish finished product') GO INSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'PRT', N'Product used for parts') GO INSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'RF', N'Product needs to be repared befor Sale') GO INSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'RP', N'Product is turned into new product') GO INSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'S', N'Product is ready for sale') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Amoire', 1, 70.0000, N'S') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Bookshelve', 2, 80.0000, N'RP') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Broken Couch', 1, 0.0000, N'PRT') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Broken Desk', 1, 0.0000, N'PRT') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'China Hutch', 1, 100.0000, N'RP') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Clock', 2, 8.0000, N'S') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Coffee Table', 1, 50.0000, N'S') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Couch', 1, 100.0000, N'RF') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Desk', 2, 30.0000, N'RF') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Desk Chair', 2, 25.0000, N'S') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Dressor', 1, 53.0000, N'S') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Grandfather Clock', 1, 45.0000, N'S') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Lamp', 3, 45.0000, N'S') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Latern', 1, 12.0000, N'RF') GO
  • 37. 33 INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Mirror', 1, 40.0000, N'S') GO INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Night Stand', 3, 100.0000, N'S') GO SET IDENTITY_INSERT [dbo].[SalesInvoiceDetails] ON GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (1, N'Coffee Table', 2, 1, 600.0000, 600.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (2, N'Lamp', 5, 1, 120.0000, 120.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (3, N'Night Stand', 4, 2, 620.0000, 1240.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (4, N'Lamp', 3, 2, 120.0000, 240.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (5, N'Mirror', 7, 1, 400.0000, 400.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (6, N'Night Stand', 7, 1, 610.0000, 610.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (7, N'Amoire', 8, 1, 4000.0000, 4000.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (8, N'Desk Chair', 9, 2, 300.0000, 600.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (9, N'Clock', 10, 1, 150.0000, 150.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (10, N'Clock', 11, 1, 150.0000, 150.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (11, N'Coffee Table', 15, 1, 500.0000, 500.0000) GO INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (13, N'Grandfather Clock', 12, 1, 1000.0000, 1000.0000) GO SET IDENTITY_INSERT [dbo].[SalesInvoiceDetails] OFF
  • 38. 34 GO SET IDENTITY_INSERT [dbo].[SalesInvoices] ON GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (2, 6, 5, CAST(N'2016-02-12' AS Date), 600.0000, CAST(0.05 AS Decimal(18, 2)), 0.0000, 570.0000, N'P') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (3, 7, 1, CAST(N'2016-04-17' AS Date), 120.0000, CAST(0.00 AS Decimal(18, 2)), 25.0000, 145.0000, N'M') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (4, 7, 2, CAST(N'2016-06-19' AS Date), 1240.0000, CAST(0.08 AS Decimal(18, 2)), 100.0000, 1240.8000, N'D') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (5, 6, 3, CAST(N'2016-07-20' AS Date), 120.0000, CAST(0.00 AS Decimal(18, 2)), 25.0000, 145.0000, N'M') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (7, 6, 3, CAST(N'2016-08-26' AS Date), 1020.0000, CAST(0.05 AS Decimal(18, 2)), 100.0000, 1069.0000, N'D') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (8, 11, 9, CAST(N'2014-12-13' AS Date), 4000.0000, CAST(0.08 AS Decimal(18, 2)), 100.0000, 3780.0000, N'D') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (9, 9, 4, CAST(N'2015-11-23' AS Date), 600.0000, CAST(0.05 AS Decimal(18, 2)), 0.0000, 570.0000, N'P') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (10, 10, 8, CAST(N'2015-11-17' AS Date), 150.0000, CAST(0.00 AS Decimal(18, 2)), 25.0000, 175.0000, N'M') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (11, 11, 1, CAST(N'2015-03-10' AS Date), 150.0000, CAST(0.00 AS Decimal(18, 2)), 25.0000, 175.0000, N'M') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (12, 8, 8, CAST(N'2015-02-13' AS Date), 1000.0000, CAST(0.08 AS Decimal(18, 2)), 0.0000, 920.0000, N'P') GO INSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue], [DeliveryMethodID]) VALUES (15, 8, 6, CAST(N'2014-12-24' AS Date), 500.0000, CAST(0.05 AS Decimal(18, 2)), 100.0000, 575.0000, N'D')
  • 39. 35 GO SET IDENTITY_INSERT [dbo].[SalesInvoices] OFF GO INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'bx', N'Box') GO INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'dz', N'Dozen') GO INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'ea', N'Each') GO INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'ft', N'Feet/Foot') GO INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'in', N'Inch') GO INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'lb', N'Pounds') GO INSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'oz', N'Ounces') GO SET IDENTITY_INSERT [dbo].[Vendors] ON GO INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City], [State], [ZipCode], [YTDSales]) VALUES (1, N'Nail House', N'Screw and Nails', N'12413 E Harbor Ave', N'Vancouver', N'WA', 98685, 30.0000) GO INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City], [State], [ZipCode], [YTDSales]) VALUES (2, N'Home Depot', N'Miscellaneous', N'344 W Clark St', N'Portland', N'OR', 97203, 45.9600) GO INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City], [State], [ZipCode], [YTDSales]) VALUES (3, N'Design Co.', N'Manufactured', N'233 E Rick St', N'Aspen', N'CO', 81611, 520.0500) GO INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City], [State], [ZipCode], [YTDSales]) VALUES (4, N'Paint Hut', N'Paint and Paint Supplies', N'50012 S Park Rd', N'Portland', N'OR', 97202, 60.0000) GO INSERT [dbo].[Vendors] ([VendorID], [VendorName], [Description], [Address], [City], [State], [ZipCode], [YTDSales]) VALUES (5, N'Lowes', N'Miscellaneous', N'987 NW Jestin St', N'Gresham', N'OR', 97080, 16.9700) GO SET IDENTITY_INSERT [dbo].[Vendors] OFF GO SET IDENTITY_INSERT [dbo].[WorkOrderLabor] ON GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (1, 8, 1, CAST(N'2016-01-01' AS Date), N'1 ', 30.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (2, 5, 1, CAST(N'2016-01-03' AS Date), N'4 ', 80.0000) GO
  • 40. 36 INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (3, 1, 1, CAST(N'2016-01-03' AS Date), N'2 ', 50.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (4, 4, 1, CAST(N'2016-01-12' AS Date), N'2 ', 40.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (5, 12, 1, CAST(N'2016-01-25' AS Date), N'1 ', 45.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (6, 8, 2, CAST(N'2016-06-14' AS Date), N'1 ', 30.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (7, 4, 2, CAST(N'2016-06-22' AS Date), N'3 ', 39.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (8, 1, 2, CAST(N'2016-07-09' AS Date), N'2 ', 50.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (9, 12, 2, CAST(N'2016-07-20' AS Date), N'1 ', 45.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (10, 4, 3, CAST(N'2016-08-16' AS Date), N'2 ', 40.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (11, 8, 4, CAST(N'2016-08-20' AS Date), N'1 ', 40.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (12, 5, 4, CAST(N'2016-09-30' AS Date), N'4 ', 80.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (13, 8, 5, CAST(N'2016-09-14' AS Date), N'1 ', 30.0000) GO INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (14, 12, 5, CAST(N'2016-09-20' AS Date), N'1 ', 45.0000) GO SET IDENTITY_INSERT [dbo].[WorkOrderLabor] OFF GO SET IDENTITY_INSERT [dbo].[WorkOrderMaterials] ON GO INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate], [MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (1, 1, CAST(N'2016-01-03' AS Date), N'Stain', 30.0000, 2, 60.0000) GO
  • 41. 37 INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate], [MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (2, 2, CAST(N'2016-06-22' AS Date), N'Nails', 10.0000, 2, 20.0000) GO INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate], [MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (3, 2, CAST(N'2016-06-23' AS Date), N'Mirror', 250.0000, 1, 250.0000) GO INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate], [MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (4, 1, CAST(N'2016-01-12' AS Date), N'Wax', 16.9700, 1, 16.9700) GO INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate], [MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (5, 3, CAST(N'2016-08-10' AS Date), N'Sand Paper', 8.9900, 4, 35.9600) GO INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate], [MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (6, 4, CAST(N'2016-08-22' AS Date), N'Trimming', 13.8500, 13, 180.0500) GO INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate], [MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (7, 1, CAST(N'2016-01-20' AS Date), N'Hinge', 90.0000, 1, 90.0000) GO INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate], [MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (8, 2, CAST(N'2016-06-30' AS Date), N'Small Nails', 5.0000, 2, 10.0000) GO INSERT [dbo].[WorkOrderMaterials] ([WorkOrderMaterialsID], [WorkOrderID], [OrderDate], [MaterialNameID], [UnitPrice], [OrderQty], [TotalPrice]) VALUES (9, 3, CAST(N'2016-08-12' AS Date), N'Nails', 10.0000, 1, 10.0000) GO SET IDENTITY_INSERT [dbo].[WorkOrderMaterials] OFF GO SET IDENTITY_INSERT [dbo].[WorkOrders] ON GO INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate], [TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (1, N'Desk', CAST(N'2016-01-01' AS Date), 200.0000, 166.9700, 360.9700) GO INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate], [TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (2, N'Bookshelve', CAST(N'2016-06-14' AS Date), 240.0000, 280.0000, 520.0000) GO INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate], [TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (3, N'Broken Desk', CAST(N'2016-08-16' AS Date), 40.0000, 45.9600, 85.9600) GO INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate], [TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (4, N'Desk', CAST(N'2016-08-20' AS Date), 100.0000, 180.0500, 280.0500) GO INSERT [dbo].[WorkOrders] ([WorkOrderID], [ProductNameID], [WorkOrderDate], [TotalEmployeeCost], [TotalMaterialCost], [TotalRepairCost]) VALUES (5, N'Coffee Table', CAST(N'2016-09-14' AS Date), 75.0000, 0.0000, 75.0000) GO SET IDENTITY_INSERT [dbo].[WorkOrders] OFF
  • 42. 38 GO ALTER TABLE [dbo].[Materials] WITH CHECK ADD CONSTRAINT [FK_Materials_UnitOfMaterials] FOREIGN KEY([UnitOfMeasureID]) REFERENCES [dbo].[UnitOfMeasure] ([UnitsOfMeasureID]) GO ALTER TABLE [dbo].[Materials] CHECK CONSTRAINT [FK_Materials_UnitOfMaterials] GO ALTER TABLE [dbo].[Materials] WITH CHECK ADD CONSTRAINT [FK_Materials_Vendor] FOREIGN KEY([VendorID]) REFERENCES [dbo].[Vendors] ([VendorID]) GO ALTER TABLE [dbo].[Materials] CHECK CONSTRAINT [FK_Materials_Vendor] GO ALTER TABLE [dbo].[Products] WITH CHECK ADD CONSTRAINT [FK_Product_ProductCondtion] FOREIGN KEY([ProductConditionID]) REFERENCES [dbo].[ProductCondtion] ([ProductConditionID]) GO ALTER TABLE [dbo].[Products] CHECK CONSTRAINT [FK_Product_ProductCondtion] GO ALTER TABLE [dbo].[SalesInvoiceDetails] WITH CHECK ADD CONSTRAINT [FK_SalesInvoiceDetails_Products] FOREIGN KEY([ProductNameID]) REFERENCES [dbo].[Products] ([ProductNameID]) GO ALTER TABLE [dbo].[SalesInvoiceDetails] CHECK CONSTRAINT [FK_SalesInvoiceDetails_Products] GO ALTER TABLE [dbo].[SalesInvoiceDetails] WITH CHECK ADD CONSTRAINT [FK_SalesInvoiceDetails_SalesInvoice] FOREIGN KEY([SalesInvoiceID]) REFERENCES [dbo].[SalesInvoices] ([SalesInvoiceID]) GO ALTER TABLE [dbo].[SalesInvoiceDetails] CHECK CONSTRAINT [FK_SalesInvoiceDetails_SalesInvoice] GO ALTER TABLE [dbo].[SalesInvoices] WITH CHECK ADD CONSTRAINT [FK_SalesInvoice_Customers] FOREIGN KEY([CustomerID]) REFERENCES [dbo].[Customers] ([CustomersID]) GO ALTER TABLE [dbo].[SalesInvoices] CHECK CONSTRAINT [FK_SalesInvoice_Customers] GO ALTER TABLE [dbo].[SalesInvoices] WITH CHECK ADD CONSTRAINT [FK_SalesInvoice_DeliveryMethod] FOREIGN KEY([DeliveryMethodID]) REFERENCES [dbo].[DeliveryMethod] ([DeliveryMethodID]) GO ALTER TABLE [dbo].[SalesInvoices] CHECK CONSTRAINT [FK_SalesInvoice_DeliveryMethod] GO ALTER TABLE [dbo].[SalesInvoices] WITH CHECK ADD CONSTRAINT [FK_SalesInvoice_Employee] FOREIGN KEY([EmployeeID]) REFERENCES [dbo].[Employees] ([EmployeeID]) GO ALTER TABLE [dbo].[SalesInvoices] CHECK CONSTRAINT [FK_SalesInvoice_Employee] GO ALTER TABLE [dbo].[WorkOrderLabor] WITH CHECK ADD CONSTRAINT [FK_LaborCosts_Employees] FOREIGN KEY([EmployeeID]) REFERENCES [dbo].[Employees] ([EmployeeID]) GO ALTER TABLE [dbo].[WorkOrderLabor] CHECK CONSTRAINT [FK_LaborCosts_Employees] GO
  • 43. 39 ALTER TABLE [dbo].[WorkOrderLabor] WITH CHECK ADD CONSTRAINT [FK_LaborCosts_WorkOrders] FOREIGN KEY([WorkOrderID]) REFERENCES [dbo].[WorkOrders] ([WorkOrderID]) GO ALTER TABLE [dbo].[WorkOrderLabor] CHECK CONSTRAINT [FK_LaborCosts_WorkOrders] GO ALTER TABLE [dbo].[WorkOrderMaterials] WITH CHECK ADD CONSTRAINT [FK_WorkOrderDetails_WorkOrder] FOREIGN KEY([WorkOrderID]) REFERENCES [dbo].[WorkOrders] ([WorkOrderID]) GO ALTER TABLE [dbo].[WorkOrderMaterials] CHECK CONSTRAINT [FK_WorkOrderDetails_WorkOrder] GO ALTER TABLE [dbo].[WorkOrderMaterials] WITH CHECK ADD CONSTRAINT [FK_WorkOrderMaterials_Materials1] FOREIGN KEY([MaterialNameID]) REFERENCES [dbo].[Materials] ([MaterialNameID]) GO ALTER TABLE [dbo].[WorkOrderMaterials] CHECK CONSTRAINT [FK_WorkOrderMaterials_Materials1] GO ALTER TABLE [dbo].[WorkOrders] WITH CHECK ADD CONSTRAINT [FK_WorkOrders_Products] FOREIGN KEY([ProductNameID]) REFERENCES [dbo].[Products] ([ProductNameID]) GO ALTER TABLE [dbo].[WorkOrders] CHECK CONSTRAINT [FK_WorkOrders_Products] GO