57
City Home Cover Page Team Members: Nadine Miller Chris Morgan Yuri Voronyuk

City Home Database Design

Embed Size (px)

Citation preview

Page 1: City Home Database Design

City Home Cover Page

Team Members:Nadine MillerChris Morgan

Yuri Voronyuk

MIS 372December 10th, 2016

Page 2: City Home Database Design

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.

ii

Page 3: City Home Database Design

Table of Contents

Table of Contents

CITY HOME COVER PAGE I

EXECUTIVE SUMMARY II

TABLE OF CONTENTS III

REVISIONS AND REPORTS 1

NARRATIVE 1ORGANIZATIONAL OVERVIEW: 1PROCESS OVERVIEW: 1DETAILED PROCESS DESCRIPTION: 2ENTER NEW PRODUCT: 2SEND TO INSPECTION: 2SEND WORK ORDER TO WORKSHOP AND FULFILL WORK ORDER: 2CREATE QR CODE: 3SET PRICE: 3PRINT QR CODE AND CREATE PRODUCT SHOWCASE: 3SELL PRODUCT: 3BUSINESS PROCESS END 3LIST OF TRANSACTIONS AND OBJECTS WITH ATTRIBUTES: 4OBJECTS: 4TRANSACTIONS: 4

FLOW CHARTS 5

CITY HOME BUSINESS PROCESS 5CITY HOME INSPECTION SUB PROCESS 6CITY HOME WORK ORDER SUB PROCESS 7CITY HOME SALES SUB PROCESS 8

ENTITY-RELATIONSHIP (E-R) DIAGRAM 9

E-R DIAGRAM FOR CITY HOME 9CARDINALITY CONSTRAINTS: 9DATA TYPES: 10

DATA DIAGRAM 11

CITY HOME DATABASE SCHEMA: 11DESIGN EXPLANATION 12OBJECT TABLES 12TRANSACTION TABLES 12

iii

Page 4: City Home Database Design

EXAMPLES OF CALCULATED DATA 12

PRJ2 WORK ORDER REPORT 12

REPORT DOCUMENTATION: 12WORK ORDER REPORT 13SQL QUERIES 13REPORT HEADER 13FIRST PART OF REPORT 14SECOND PART OF REPORT BODY 14

PRJ3 SALES STAFF ACTIVITY REPORT 15

REPORT DOCUMENTATION: 15REPORT PROCEDURE 15SQL STORED PROCEDURE QUERIES 16SALES STAFF ACTIVITY REPORT 16

UPDATED PRJ2 EXAMPLE DATA 17

DATABASE SCRIPT 25

iv

Page 5: City Home Database Design

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 immediately placed in the store, most products need to be repaired or repurposed. This is 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 while still keeping the original products integrity and unique style. This inspection process is usually completed within a day and the workshop process within a week.

1

Page 6: City Home Database Design

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 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 information is sent to the Data Store. The main goal of recording this initial information is to 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.

2

Page 7: City Home Database Design

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 materials are needed to work on the product. Materials include 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.

Create QR Code: After the work order is fulfilled, 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 give an appraisal. The workshop assigns a price based 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

3

Page 8: City Home Database Design

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.

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

4

Page 9: City Home Database Design

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 details of the invoice are recorded once, on a single invoice, for a single customer. 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

Flow Charts

5

Page 10: City Home Database Design

City Home Business Process

Figure 1 shows the main City Home business process. It tracks the Product from the time it enters the warehouse until 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 Home originally did not have any kind of automated process to record inspection of the product or work done to each product.

6

Page 11: City Home Database Design

City Home Inspection Sub Process

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 not need 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

Page 12: City Home Database Design

City Home Work Order Sub Process

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

Page 13: City Home Database Design

City Home Sales Sub Process

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

Page 14: City Home Database Design

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. Each product 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.

10

Page 15: City Home Database Design

Each material can be ordered to fulfill one or many work orders, but one work order may or may not need materials.

Data Types:

Employee (object) data used to record details of the employeeo EmployeeID – integer, unique identifier [primary key]o Title – texto Last name, first name – texto PhoneNumber – integer o HireDate – dateo HourlyWage – decimal

Work order (transaction) data used to record details of the work ordero WorkOrderID – integer, unique identifier [primary key]o EmployeeID – integer [foreign key]o ProductID – integer [foreign key]o WorkOrderDate – date o EmployeeHours – decimal o EmployeeCost – moneyo TotalMaterialCost – moneyo TotalCost – money

Product (object) data used to record details of the itemo 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 invoiceo SalesInvoiceID – integer, unique identifier [primary key]o CustomerID – integer, unique identifier [foreign key]o EmployeeID – integer, unique identifier [foreign key]o SalesDate – dateo SubTotal – moneyo Discount – integer o ShippingCost – moneyo TotalDue – moneyo DeliveryMethodID – integer [foreign key]

Customer (object) data is used to record details of the customero CustomerID – integer, unique identifier [primary key]o LastName – text o FirstName – text

11

Page 16: City Home Database Design

o Address – text o City – text o State – text o ZipCode – integer o PhoneNumber – integer o YTDPurchased – money

Material (object) data is used to record details of the materialo MaterialsID– text, unique identifier [primary key]o VendorID – integer [foreign key]o UnitOfMeasureID – integer [foreign key]o ListPrice – moneyo Description – text

Data Diagram

City Home Database Schema:

Figure 6 is the database diagram for City Home’s work order and sales process.

12

Page 17: City Home Database Design

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.

PRJ2 Work 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 are important because it specifies which materials were used to work on the product and at what cost. The work order is basically the focal point of City Home’s workshop process and necessary in determining 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 is a result of the following: “Inspect Product,” “Assign a 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

13

Page 18: City Home Database Design

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 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 #: 1Date: 1/1/2016Product Name: DeskProduct Purchase Price: $30.00 Total Work Order Cost: $411.97

Employee  InformationName Title Hourly Wage Hours Cost Work DateYogi Baggins Inspector $30.00 1 $30.00 1/1/2016Mark Westin Workshop Worker $20.00 4 $80.00 1/3/2016Greg Mullins Supervisor $25.00 2 $50.00 1/3/2016Emily Westin Workshop Worker $20.00 2 $40.00 1/12/2016Russell Wilson Appraiser $45.00 1 $45.00 1/25/2016Material Information

Material Name Order Quantity Unit of Meas. UnitPriceTotal Price

Order Date

Stain 2 oz $30 $60.00 1/3/2016Wax 1 lb $16.97 $16.97 1/12/2016Hinge 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

14

Page 19: City Home Database Design

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.ProductNameWHERE (dbo.WorkOrders.WorkOrderID = 1)

Work Order # Work Order Date Product Name Total Repair Cost1 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.MaterialNameWHERE (dbo.WorkOrderMaterials.WorkOrderID = 1)ORDER BY [Order Date]

Material Name Order Date Order Quantity Unit Of Meas. Unit Price Total PriceStain 1/3/16 2 oz 30 60Wax 1/12/16 1 lb 16.97 16.97Hinge 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.EmployeeIDWHERE (dbo.WorkOrderLabor.WorkOrderID = 1)ORDER BY [Work Date]

15

Page 20: City Home Database Design

Title Last Name First Name Work Date Hourly Wage Hours Employee CostInspector Baggins Yogi 1/1/16 30 1 30Workshop Worker Westin Mark 1/3/16 20 4 80Supervisor Mullins Greg 1/3/16 25 2 50Workshop Worker Westin Emily 1/12/16 20 2 40Appraiser 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.

PRJ3 Sales 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 all sales 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 financially and what possible changes should be made in order to meet its financial goals. 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 usingGOCREATEPROCEDURE [dbo].[SalesWithTotalsPRJ] --Name of the stored procedure

16

Page 21: City Home Database Design

(--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 sumAVG(dbo.SalesInvoices.SubTotal)AS [Average Sales],--aggregation by the averageCOUNT(dbo.SalesInvoices.SalesInvoiceID)AS [Number of Sales] --aggregation by countFROMdbo.EmployeesINNERJOINdbo.SalesInvoicesONdbo.Employees.EmployeeID=dbo.SalesInvoices.EmployeeIDWHERE (dbo.SalesInvoices.SalesDate>=CONVERT(DATETIME, @startDate, 102))--filter for the start dateAND(dbo.SalesInvoices.SalesDate<=CONVERT(DATETIME, @endDate, 102))--filter for the end dateGROUPBYdbo.Employees.FirstName--Aggregator for groupingORDERBYSUM(dbo.SalesInvoices.SubTotal)DESC--result set by descending order--The totals tableSELECTTOP (100)PERCENTSUM(SubTotal)AS [Total Sales],--aggregation by the sumAVG(SubTotal)AS [Average Sales],--aggregation by the averageCOUNT(SalesInvoiceID)AS [Number of Sales] --aggregation by the countFROMdbo.SalesInvoicesWHERE (SalesDate>=CONVERT(DATETIME, @startDate, 102))--filter for the start dateAND(SalesDate<=CONVERT(DATETIME, @endDate, 102))--filter by the end dateORDERBYSUM(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/2016First Name Total Sales Average Sales Number of SalesJennifer $4,150.00 $2,075.00 2Abby $1,740.00 $580.00 3Yogi $1,500.00 $750.00 2Angus $1,360.00 $680.00 2Ralph $600.00 $600.00 1Marge $150.00 $150.00 1

17

Page 22: City Home Database Design

Total: $9,500.00 $863.64 11Figure 8 show the sales staff activity report for City Home for the data 1/1/2014 to 12/31/2016.

18

Page 23: City Home Database Design

Updated PRJ2 Example Data

Product Name TableProductName AmountPurchased PurchasedPrice ProductConditionIDArmoire 1 70 SBookshelf 2 80 RPBroken Couch 1 0 PRTBroken Desk 1 0 PRTChina Hutch 1 100 RPClock 2 8 SCoffee Table 1 50 SCouch 1 100 RFDesk 2 30 RFDesk Chair 2 25 SDresser 1 53 SGrandfather Clock 1 45 SLamp 3 45 SLantern 1 12 RFMirror 1 40 SNight Stand 3 100 S

Table 4 contains data for the Products table. Yellow highlights show that one ProductConditionID can appear many times.

Product Condition TableProductConditionID DesriptionPRT Product used for partsRF Product needs to be repaired before SaleRP Product is turned into new productS Product is ready for sale

Table 5 contains data for the ProductCondition table.

17

Page 24: City Home Database Design

Work Order Labor TableWorkOrderLaborID

EmployeeID

WorkOrderID

WorkDate Hours

EmployeeCost

1 8 1 1/1/16 1 302 5 1 1/3/16 4 803 1 1 1/3/16 2 504 4 1 1/12/16 2 405 12 1 1/25/16 1 456 8 2 6/14/16 1 307 4 2 6/22/16 3 398 1 2 7/9/16 2 509 12 2 7/20/16 1 4510 4 3 8/16/16 2 4011 8 4 8/20/16 1 4012 5 4 9/30/16 4 8013 8 5 9/14/16 1 3014 12 5 9/20/16 1 45

Table 6 13 contains data for the WorkOrderLabor table.

Work Order TableWorkOrderID ProductName WorkOrderDate TotalEmployeeCost TotalMaterialCost TotalRepairCost1 Desk 1/1/16 200 166.97 360.972 Bookshelf 6/14/16 240 280 5203 Broken Desk 8/16/16 40 45.96 85.964 Desk 8/20/16 100 180.05 280.055 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.

18

Page 25: City Home Database Design

Work Order Materials Table

WorkOrderMaterialsIDWorkOrderID OrderDate

MaterialName UnitPrice OrderQty TotalPrice

1 1 1/3/16 Stain 30 2 602 2 6/22/16 Nails 10 2 203 2 6/23/16 Mirror 250 1 2504 1 1/12/16 Wax 16.97 1 16.975 3 8/10/16 Sand Paper 8.99 4 35.966 4 8/22/16 Trimming 13.85 13 180.057 1 1/20/16 Hinge 90 1 908 2 6/30/16 Small Nails 5 2 109 3 8/12/16 Nails 10 1 10

Table 8 contains data for the WorkOrderMaterials table.

Materials TableMaterialName VendorID UnitOfMeasureID ListPrice DescriptionBolts 2 ea 1.99 3 inch BoltsCable 5 Ft 1.34 14 gauge Crews 1 bx 12.99 One inchHinge 3 ea 90 Special three-way hingeMirror 3 ea 250 Star shapedNails 1 bx 10 Ten PennyNuts 2 ea 0.45 Match 3 inch BoltsPaint 4 oz 15 Egg shell whiteSand Paper 2 ea 8.99 Extra FineSmall Nails 1 dz 5 Finishing nailsStain 4 oz 30 Honeycomb ColoredTrimming 3 in 13.85 Celtic Metal TrimmingWax 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.

19

Page 26: City Home Database Design

Units of Measure Table UnitsOfMeasureID Descriptionsbx Boxdz Dozenea Eachft Feet/Footin Inchlb Poundsoz Ounces

Table 10 contains data for the UnitsOfMeasure table.

Vendor TableVendorID VendorName Description Address City State ZipCode YTDSales1 Nail House Screw and Nails 12413 E Harbor Ave Vancouver WA 98685 302 Home Depot Miscellaneous 344 W Clark St Portland OR 97203 45.963 Design Co. Manufactured 233 E Rick St Aspen CO 81611 520.05

4 Paint HutPaint and Paint Supplies 50012 S Park Rd Portland OR 97202 60

5 Lowes Miscellaneous 987 NW Jestin St Gresham OR 97080 16.97Table 11 contains data for the Vendors table.

20

Page 27: City Home Database Design

Employee TableEmployeeID Title LastName FirstName PhoneNumber HireDate HourlyWage

1 Supervisor Mullins Greg 5552341243 3/12/05 25

2Warehouse Worker Caarp Jessica 5552124566 10/23/10 15

3Warehouse Worker Tao Matt 5555641234 1/1/12 13

4Workshop Worker Westin Emily 5552144455 3/12/05 20

5Workshop Worker Westin Mark 5552145544 3/12/05 20

6 Sales Manager Johnson Abby 5559403431 1/12/06 157 Sales Associate Simmons Angus 5556759767 1/17/10 128 Inspector Baggins Yogi 5555061254 1/23/06 309 Sales Associate Wiggins Ralph 5559861267 2/18/09 12

10 Sales Associate Simpson Marge 5554942223 2/12/06 12

11Sales Ass. Manager Arrow Jennifer 6533342340 3/10/10 13

12 Appraiser Wilson Russell 6565442456 6/17/09 45Table 12 contains data for the Employees table.

Sales Invoice TableSalesInvoiceID EmployeeID CustomerID SalesDate SubTotal Discount ShippingCost TotalDue DeliveryMethodID

21

Page 28: City Home Database Design

2 6 5 2/12/16 600 0.05 0 570 P3 7 1 4/17/16 120 0 25 145 M4 7 2 6/19/16 1240 0.08 100 1240.8 D5 6 3 7/20/16 120 0 25 145 M7 6 3 8/26/16 1020 0.05 100 1069 D8 11 9 12/13/14 4000 0.08 100 3780 D9 9 4 11/23/15 600 0.05 0 570 P10 10 8 11/17/15 150 0 25 175 M11 11 1 3/10/15 150 0 25 175 M12 8 8 2/13/15 1000 0.08 0 920 P15 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.

Sales Invoice Details TableSalesInvoiceDetailsID ProductName SalesInvoiceID Quantity UnitPrice LineTotal

22

Page 29: City Home Database Design

1 Coffee Table 2 1 600 6002 Lamp 5 1 120 1203 Night Stand 4 2 620 12404 Lamp 3 2 120 2405 Mirror 7 1 400 4006 Night Stand_ 7_ 1 610 6107 Amoire 8 1 4000 40008 Desk Chair 9 2 300 6009 Clock 10 1 150 15010 Clock 11 1 150 15011 Coffee Table 15 1 500 500

13Grandfather 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 TableDeliveryMethodID DescriptionD Delivery shipmentM Shipping through US mailP Pick-up from warehouse

Table 15 contains data for the DeliveryMethods table

Customer TableCustomersID LastName FirstName Address City State ZipCode PhoneNumber YTDPurchases

1 Marsh Sally 432 E Jack St Burlington WA 98564 5556061234 320

23

Page 30: City Home Database Design

2 Dawson Creek 5674 W Worg Rd Portland OR 97022 5554951245 1240.83 Boyd Frankie 3945 N Hobbit Ave Nampa ID 56456 5551235645 1214

4 knight Katie 6785 E Alderran StVancouver WA 97048 5554321960 570

5 Konobi Obi-Wan 1233 Tatooine Dr Las Vegas NV 89101 5554443333 5706 Marley Jacob 1256 Christmas Rd Salem MA 60531 6694332332 5757 Crachett Bob 4955 Tiny Tin Ln Annaplolis MD 59643 4953122344 0

8 Cricket Jimmy1971 Walt Disney World Orlando FL 32830 4955355931 1095

9 Stark Tony 10880 Malibu Point Malibu CA 90263 4544122233 3780Table 16 contains data for the Customers table.

24

Page 31: City Home Database Design

Database Script

USE [CityHome02]GO/****** Object: Table [dbo].[Customers] Script Date: 12/9/16 1:27:29 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Employees](

[EmployeeID] [int] IDENTITY(1,1) NOT NULL,[Title] [nvarchar](50) NULL,[LastName] [nvarchar](255) NULL,

25

Page 32: City Home Database Design

[FirstName] [nvarchar](255) NULL,[PhoneNumber] [bigint] NULL,[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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Products](

[ProductNameID] [nvarchar](255) NOT NULL,[AmountPurchased] [int] NULL,

26

Page 33: City Home Database Design

[PurchasedPrice] [money] NULL,[ProductConditionID] [nvarchar](255) NULL,

CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED (

[ProductNameID] 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].[SalesInvoiceDetails] Script Date: 12/9/16 1:27:30 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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

27

Page 34: City Home Database Design

GOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[UnitOfMeasure](

[UnitsOfMeasureID] [nvarchar](255) NOT NULL,[Descriptions] [nvarchar](255) NULL,

CONSTRAINT [PK_UnitOfMaterials] PRIMARY KEY CLUSTERED (

[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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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

28

Page 35: City Home Database Design

/****** Object: Table [dbo].[WorkOrderMaterials] Script Date: 12/9/16 1:27:30 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[WorkOrderMaterials](

[WorkOrderMaterialsID] [int] IDENTITY(1,1) NOT NULL,[WorkOrderID] [int] NULL,[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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE 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]

GOSET IDENTITY_INSERT [dbo].[Customers] ON

GOINSERT [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)GOINSERT [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)GOINSERT [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

29

Page 36: City Home Database Design

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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOSET IDENTITY_INSERT [dbo].[Customers] OFFGOINSERT [dbo].[DeliveryMethod] ([DeliveryMethodID], [Description]) VALUES (N'D', N'Delivery shipment')GOINSERT [dbo].[DeliveryMethod] ([DeliveryMethodID], [Description]) VALUES (N'M', N'Shipping through US mail')GOINSERT [dbo].[DeliveryMethod] ([DeliveryMethodID], [Description]) VALUES (N'P', N'Pick-up from warehouse')GOSET IDENTITY_INSERT [dbo].[Employees] ON

GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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

30

Page 37: City Home Database Design

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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOSET IDENTITY_INSERT [dbo].[Employees] OFFGOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Bolts', 2, N'ea', 1.9900, N'3 inch Bolts')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Cable', 5, N'Ft', 1.3400, N'14 gauge ')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Crews', 1, N'bx', 12.9900, N'One inch')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Hinge', 3, N'ea', 90.0000, N'Special three-way hinge')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Mirror', 3, N'ea', 250.0000, N'Star shaped')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Nails', 1, N'bx', 10.0000, N'Ten Penny')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Nuts', 2, N'ea', 0.4500, N'Match 3 inch Bolts')GO

31

Page 38: City Home Database Design

INSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Paint', 4, N'oz', 15.0000, N'Egg shell white')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Sand Paper', 2, N'ea', 8.9900, N'Extra Fine')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Small Nails', 1, N'dz', 5.0000, N'Finishing nails')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Stain', 4, N'oz', 30.0000, N'Honeycomb Colored')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Trimming', 3, N'in', 13.8500, N'Celtic Metal Trimming')GOINSERT [dbo].[Materials] ([MaterialNameID], [VendorID], [UnitOfMeasureID], [ListPrice], [Description]) VALUES (N'Wax', 5, N'lb', 16.9700, N'To polish finished product')GOINSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'PRT', N'Product used for parts')GOINSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'RF', N'Product needs to be repared befor Sale')GOINSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'RP', N'Product is turned into new product')GOINSERT [dbo].[ProductCondtion] ([ProductConditionID], [Desription]) VALUES (N'S', N'Product is ready for sale')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Amoire', 1, 70.0000, N'S')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Bookshelve', 2, 80.0000, N'RP')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Broken Couch', 1, 0.0000, N'PRT')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Broken Desk', 1, 0.0000, N'PRT')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'China Hutch', 1, 100.0000, N'RP')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Clock', 2, 8.0000, N'S')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Coffee Table', 1, 50.0000, N'S')GO

32

Page 39: City Home Database Design

INSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Couch', 1, 100.0000, N'RF')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Desk', 2, 30.0000, N'RF')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Desk Chair', 2, 25.0000, N'S')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Dressor', 1, 53.0000, N'S')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Grandfather Clock', 1, 45.0000, N'S')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Lamp', 3, 45.0000, N'S')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Latern', 1, 12.0000, N'RF')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Mirror', 1, 40.0000, N'S')GOINSERT [dbo].[Products] ([ProductNameID], [AmountPurchased], [PurchasedPrice], [ProductConditionID]) VALUES (N'Night Stand', 3, 100.0000, N'S')GOSET IDENTITY_INSERT [dbo].[SalesInvoiceDetails] ON

GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (1, N'Coffee Table', 2, 1, 600.0000, 600.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (2, N'Lamp', 5, 1, 120.0000, 120.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (3, N'Night Stand', 4, 2, 620.0000, 1240.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (4, N'Lamp', 3, 2, 120.0000, 240.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (5, N'Mirror', 7, 1, 400.0000, 400.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (6, N'Night Stand', 7, 1, 610.0000, 610.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (7, N'Amoire', 8, 1, 4000.0000, 4000.0000)GO

33

Page 40: City Home Database Design

INSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (8, N'Desk Chair', 9, 2, 300.0000, 600.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (9, N'Clock', 10, 1, 150.0000, 150.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (10, N'Clock', 11, 1, 150.0000, 150.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (11, N'Coffee Table', 15, 1, 500.0000, 500.0000)GOINSERT [dbo].[SalesInvoiceDetails] ([SalesInvoiceDetailsID], [ProductNameID], [SalesInvoiceID], [Quantity], [UnitPrice], [LineTotal]) VALUES (13, N'Grandfather Clock', 12, 1, 1000.0000, 1000.0000)GOSET IDENTITY_INSERT [dbo].[SalesInvoiceDetails] OFFGOSET IDENTITY_INSERT [dbo].[SalesInvoices] ON

GOINSERT [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')GOINSERT [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')GOINSERT [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')GOINSERT [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')GOINSERT [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')GOINSERT [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')GOINSERT [dbo].[SalesInvoices] ([SalesInvoiceID], [EmployeeID], [CustomerID], [SalesDate], [SubTotal], [Discount], [ShippingCost], [TotalDue],

34

Page 41: City Home Database Design

[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')GOINSERT [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')GOINSERT [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')GOINSERT [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')GOINSERT [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')GOSET IDENTITY_INSERT [dbo].[SalesInvoices] OFFGOINSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'bx', N'Box')GOINSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'dz', N'Dozen')GOINSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'ea', N'Each')GOINSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'ft', N'Feet/Foot')GOINSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'in', N'Inch')GOINSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'lb', N'Pounds')GOINSERT [dbo].[UnitOfMeasure] ([UnitsOfMeasureID], [Descriptions]) VALUES (N'oz', N'Ounces')GOSET IDENTITY_INSERT [dbo].[Vendors] ON

GOINSERT [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)GOINSERT [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

35

Page 42: City Home Database Design

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)GOINSERT [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)GOINSERT [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)GOSET IDENTITY_INSERT [dbo].[Vendors] OFFGOSET IDENTITY_INSERT [dbo].[WorkOrderLabor] ON

GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (1, 8, 1, CAST(N'2016-01-01' AS Date), N'1 ', 30.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (2, 5, 1, CAST(N'2016-01-03' AS Date), N'4 ', 80.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (3, 1, 1, CAST(N'2016-01-03' AS Date), N'2 ', 50.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (4, 4, 1, CAST(N'2016-01-12' AS Date), N'2 ', 40.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (5, 12, 1, CAST(N'2016-01-25' AS Date), N'1 ', 45.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (6, 8, 2, CAST(N'2016-06-14' AS Date), N'1 ', 30.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (7, 4, 2, CAST(N'2016-06-22' AS Date), N'3 ', 39.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (8, 1, 2, CAST(N'2016-07-09' AS Date), N'2 ', 50.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (9, 12, 2, CAST(N'2016-07-20' AS Date), N'1 ', 45.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (10, 4, 3, CAST(N'2016-08-16' AS Date), N'2 ', 40.0000)GO

36

Page 43: City Home Database Design

INSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (11, 8, 4, CAST(N'2016-08-20' AS Date), N'1 ', 40.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (12, 5, 4, CAST(N'2016-09-30' AS Date), N'4 ', 80.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (13, 8, 5, CAST(N'2016-09-14' AS Date), N'1 ', 30.0000)GOINSERT [dbo].[WorkOrderLabor] ([WorkOrderLaborID], [EmployeeID], [WorkOrderID], [WorkDate], [Hours], [EmployeeCost]) VALUES (14, 12, 5, CAST(N'2016-09-20' AS Date), N'1 ', 45.0000)GOSET IDENTITY_INSERT [dbo].[WorkOrderLabor] OFFGOSET IDENTITY_INSERT [dbo].[WorkOrderMaterials] ON

GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOSET IDENTITY_INSERT [dbo].[WorkOrderMaterials] OFF

37

Page 44: City Home Database Design

GOSET IDENTITY_INSERT [dbo].[WorkOrders] ON

GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOINSERT [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)GOSET IDENTITY_INSERT [dbo].[WorkOrders] OFFGOALTER TABLE [dbo].[Materials] WITH CHECK ADD CONSTRAINT [FK_Materials_UnitOfMaterials] FOREIGN KEY([UnitOfMeasureID])REFERENCES [dbo].[UnitOfMeasure] ([UnitsOfMeasureID])GOALTER TABLE [dbo].[Materials] CHECK CONSTRAINT [FK_Materials_UnitOfMaterials]GOALTER TABLE [dbo].[Materials] WITH CHECK ADD CONSTRAINT [FK_Materials_Vendor] FOREIGN KEY([VendorID])REFERENCES [dbo].[Vendors] ([VendorID])GOALTER TABLE [dbo].[Materials] CHECK CONSTRAINT [FK_Materials_Vendor]GOALTER TABLE [dbo].[Products] WITH CHECK ADD CONSTRAINT [FK_Product_ProductCondtion] FOREIGN KEY([ProductConditionID])REFERENCES [dbo].[ProductCondtion] ([ProductConditionID])GOALTER TABLE [dbo].[Products] CHECK CONSTRAINT [FK_Product_ProductCondtion]GOALTER TABLE [dbo].[SalesInvoiceDetails] WITH CHECK ADD CONSTRAINT [FK_SalesInvoiceDetails_Products] FOREIGN KEY([ProductNameID])REFERENCES [dbo].[Products] ([ProductNameID])GOALTER TABLE [dbo].[SalesInvoiceDetails] CHECK CONSTRAINT [FK_SalesInvoiceDetails_Products]GOALTER TABLE [dbo].[SalesInvoiceDetails] WITH CHECK ADD CONSTRAINT [FK_SalesInvoiceDetails_SalesInvoice] FOREIGN KEY([SalesInvoiceID])REFERENCES [dbo].[SalesInvoices] ([SalesInvoiceID])GOALTER TABLE [dbo].[SalesInvoiceDetails] CHECK CONSTRAINT [FK_SalesInvoiceDetails_SalesInvoice]GO

38

Page 45: City Home Database Design

ALTER TABLE [dbo].[SalesInvoices] WITH CHECK ADD CONSTRAINT [FK_SalesInvoice_Customers] FOREIGN KEY([CustomerID])REFERENCES [dbo].[Customers] ([CustomersID])GOALTER TABLE [dbo].[SalesInvoices] CHECK CONSTRAINT [FK_SalesInvoice_Customers]GOALTER TABLE [dbo].[SalesInvoices] WITH CHECK ADD CONSTRAINT [FK_SalesInvoice_DeliveryMethod] FOREIGN KEY([DeliveryMethodID])REFERENCES [dbo].[DeliveryMethod] ([DeliveryMethodID])GOALTER TABLE [dbo].[SalesInvoices] CHECK CONSTRAINT [FK_SalesInvoice_DeliveryMethod]GOALTER TABLE [dbo].[SalesInvoices] WITH CHECK ADD CONSTRAINT [FK_SalesInvoice_Employee] FOREIGN KEY([EmployeeID])REFERENCES [dbo].[Employees] ([EmployeeID])GOALTER TABLE [dbo].[SalesInvoices] CHECK CONSTRAINT [FK_SalesInvoice_Employee]GOALTER TABLE [dbo].[WorkOrderLabor] WITH CHECK ADD CONSTRAINT [FK_LaborCosts_Employees] FOREIGN KEY([EmployeeID])REFERENCES [dbo].[Employees] ([EmployeeID])GOALTER TABLE [dbo].[WorkOrderLabor] CHECK CONSTRAINT [FK_LaborCosts_Employees]GOALTER TABLE [dbo].[WorkOrderLabor] WITH CHECK ADD CONSTRAINT [FK_LaborCosts_WorkOrders] FOREIGN KEY([WorkOrderID])REFERENCES [dbo].[WorkOrders] ([WorkOrderID])GOALTER TABLE [dbo].[WorkOrderLabor] CHECK CONSTRAINT [FK_LaborCosts_WorkOrders]GOALTER TABLE [dbo].[WorkOrderMaterials] WITH CHECK ADD CONSTRAINT [FK_WorkOrderDetails_WorkOrder] FOREIGN KEY([WorkOrderID])REFERENCES [dbo].[WorkOrders] ([WorkOrderID])GOALTER TABLE [dbo].[WorkOrderMaterials] CHECK CONSTRAINT [FK_WorkOrderDetails_WorkOrder]GOALTER TABLE [dbo].[WorkOrderMaterials] WITH CHECK ADD CONSTRAINT [FK_WorkOrderMaterials_Materials1] FOREIGN KEY([MaterialNameID])REFERENCES [dbo].[Materials] ([MaterialNameID])GOALTER TABLE [dbo].[WorkOrderMaterials] CHECK CONSTRAINT [FK_WorkOrderMaterials_Materials1]GOALTER TABLE [dbo].[WorkOrders] WITH CHECK ADD CONSTRAINT [FK_WorkOrders_Products] FOREIGN KEY([ProductNameID])REFERENCES [dbo].[Products] ([ProductNameID])GOALTER TABLE [dbo].[WorkOrders] CHECK CONSTRAINT [FK_WorkOrders_Products]GO

39

Page 46: City Home Database Design

40