Project Steps: 1. Database Design 1.1. Design and create a database in third normal form based on the following requirements: • Each Job is for a specific customer and there can be more than one job per customer. • The name and address must be tracked for each customer. • Each job is described by up to 2000 characters. • Each job has a status of ‘open, ‘in process’, or ‘complete’. • Each job has a start date and end date. • Multiple materials can be used on each job. • Multiple quantities of the same material can be used on each job. • Materials can be used on multiple jobs. • Each material is purchased by the company via a Vendor at a fixed cost per unit. • Each Vendor of the materials must be tracked with the vendor name and address • The number of hours worked by each worker on each job must be tracked. • The name, hire date, and hourly rate, and skills must be tracked for each worker. • Workers can have more than one skill. 1.2. Create foreign key constraints to enforce referential integrity for all relationships. 2. Add Data 2.1. Populate each table with test data. Make sure that you have sufficient data to test all indicated Updates, Deletes, and Queries. 3. Update and Deletes (2 points) 3.1. Create SQL to update the address for a specific customer. Include a select statement before and after the update. 3.2. Create SQL to increase the hourly rate by $2 for each worker that has been an employee for at least 1 year. Include a select before and after the update. Make sure that you have data so that some rows are updated and others are not. 3.3. Create SQL to delete a specific job that has associated work hours and materials assigned to it. Include a select before and after the statement(s). 4. Queries (3 points each) 4.1 Write a query to list all jobs that are in process. Include the Job ID and Description, Customer ID and name, and the start date. Order by the Job ID. 4.2 Write a query to list all complete jobs for a specific customer and the materials used on each job. Include the quantity, unit cost, and total cost for each material on each job. Order by Job ID and material ID. Note: Select a customer that has at least 3 complete jobs and at least 1 open job and 1 in process job. At least one of the complete jobs should have multiple materials. If needed, go back to your inserts and add data. 4.3 This step should use the same customer as in step 4.2. Write a query to list the total cost for all materials for each completed job for the customer. Use the data returned in step 4.2 to validate your results. 4.4 Write a query to list all jobs that have work entered for them. Include the job ID, job description, and job status description. List the total hours worked for each job with the lowest, highest, and average hourly rate. The average hourly rate should be weighted based on the number of hours worked at that rate. Make sure that your data includes at least one job that does not have hours logged. This job should not be included in the query. Order by highest to lowest average hourly rate. 4.5 Write a query that lists all materials that have not been used on any jobs. Include Material ID and Description. Order by Material ID. 4.6 Create a query that lists all workers with a specific skill, their hire date, and the total number of jobs that they worked on. List the Skill ID and description with each row. Order by Worker ID. 4.7 Create a query that lists all workers that worked greater than 20 hours for all jobs that they worked on. Include the Worker ID and name, number of hours worked, and number of jobs that they worked on. Order by Worker ID. 4.8 Create a view that includes the labor costs associated with each job. Include Customer ID and Name. 4.9 Use the View from 4.8 to create a query that includes the total labor cost for each customer. Order by Customer ID. 4.10 Write a query that lists all customers who are located on 'Main Street'. Include the customer Id and full address. Order by Customer ID. Make sure that you have at least three customers on 'Main Street' each with different house numbers. Make sure that you also have customers that are not on 'Main Street'. 4.11 Write a query to list completed jobs that started and ended in the same month. List Job, Job Status, Start Date and End Date. 4.12 Create a query to list workers that worked on three or more jobs for the same customer. 4.13 Create a query to list all workers and their total # of skills. Make sure that you have workers that have multiple skills and that you have at least 1 worker with no skills. The worker with no skills should be included with a total number of skills = 0. Order by Worker ID. 4.14 Write a query to list the total Charge to the customer for each job. Calculate the total charge to the customer as the total cost of materials + total Labor costs + 30% Profit. 4.15 Write a query that totals what is owed to each vendor for a particular job.







COPYABLE CODE
Create table
CREATE TABLE Work
(
intWork_ID INTEGER
,strFirst_name VARCHAR(30) NOT NULL
,strLast_name VARCHAR(30) NOT NULL
,dteHire_date DATE NOT NULL
,hourrate INTEGER
,CONSTRAINT Work_prk PRIMARY KEY( intWork_ID )
)
CREATE TABLE Statustable
(
intJob_statusID INTEGER NOT NULL
,strJob_stat VARCHAR(30) NOT NULL
,CONSTRAINT Statustable_PK PRIMARY KEY( intJob_statusID )
)
CREATE TABLE Skill_table
(
intIdskill INTEGER NOT NULL
,strDescripskill VARCHAR(30) NOT NULL
,CONSTRAINT Skill_table_PK PRIMARY KEY( intIdskill )
)
CREATE TABLE Material_table
(
intMaterID INTEGER NOT NULL
,strMaterName VARCHAR(30) NOT NULL
,monthlyMatCost MONEY NOT NULL
,CONSTRAINT Material_table_PK PRIMARY KEY( intMaterID )
)
CREATE TABLE Job_table
(
intJob_ID INTEGER NOT NULL
,intJob_statusID INTEGER
,strJob_descrp VARCHAR(2000) NOT NULL
,dteSdate DATE NOT NULL
,dteEdate DATE NOT NULL
,CONSTRAINT Job_table_PK PRIMARY KEY( intJob_ID )
)
CREATE TABLE Job_material
(
intMaterID INTEGER NOT NULL
,intJob_ID INTEGER NOT NULL
,intMater_quantity INTEGER
,CONSTRAINT Job_material_PK PRIMARY KEY( intJob_ID,intMaterID )
)
CREATE TABLE Customer_table
(
intCus_id INTEGER NOT NULL
,intJob_ID INTEGER NOT NULL
,strFirst_name VARCHAR(30) NOT NULL
,strLast_name VARCHAR(30) NOT NULL
,strAddre VARCHAR(30) NOT NULL
,strCity1 VARCHAR(30) NOT NULL
,strState1 VARCHAR(30) NOT NULL
,strZcode VARCHAR(30) NOT NULL
,CONSTRAINT Customer_table_PK PRIMARY KEY( intJob_ID )
)
CREATE TABLE Workskillpro
(
intWork_ID INTEGER NOT NULL
,intIdskill INTEGER NOT NULL
,CONSTRAINT Workskillpro_PK PRIMARY KEY( intWork_ID,intIdskill )
)
CREATE TABLE Job_workertable
(
intJob_ID INTEGER NOT NULL
,intWork_ID INTEGER NOT NULL
,intTothours INTEGER NOT NULL
,CONSTRAINT Job_workertable_PK PRIMARY KEY( intJob_ID,intWork_ID )
)
ALTER TABLE Work ADD CONSTRAINT Work_workskillpro_FK
FOREIGN KEY ( intWork_ID ) REFERENCES workskillpro ( intWork_ID )
ALTER TABLE Statustable ADD CONSTRAINT Statustable_job_table_FK
FOREIGN KEY ( intJob_ID ) REFERENCES TJobs ( intJob_statusID )
ALTER TABLE Skill_table ADD CONSTRAINT Skill_table_Workskillpro_FK
FOREIGN KEY ( intIdskill ) REFERENCES Workskillpro ( intIdskill )
ALTER TABLE Material_table ADD CONSTRAINT Material_table_Job_material_FK
FOREIGN KEY ( intMaterID ) REFERENCES Job_material ( intMaterID )
ALTER TABLE Job_table ADD CONSTRAINT Job_table_Job_material_FK
FOREIGN KEY ( intJob_ID ) REFERENCES Job_material ( intJob_ID )
ALTER TABLE Customer_table ADD CONSTRAINT Job_table_Customer_table_FK
FOREIGN KEY ( intJob_ID ) REFERENCES TJobs ( intJob_ID )
ALTER TABLE Job_table ADD CONSTRAINT Job_table_Job_workertable_FK
FOREIGN KEY ( intJob_ID ) REFERENCES Job_workertable ( intJob_ID )
Add data
populate each table to test the data information
INSERT INTO work (intwork_ID,strFirst_name,strLast_name,dteHire_date,hourrate)
VALUES (11,'lalith','hony','01/01/2014',10.00)
,(22,'toy','rord','01/01/2014',15.00)
,(33,'mano','lim','02/01/2013',11.00)
,(44,'vino','eull','03/01/2014',12.00)
,(55,'dad','watty','04/01/2014',11.00)
,(66,'mill','jill','05/01/20143,12.00)
INSERT INTO Statustable (intJob_statusID,strJob_stat)
VALUES (11,'Open process')
,(22,'program')
,(33,'Complete')
INSERT INTO Skill_table (intIdskill,strDescripskill)
VALUES (11,'paint street')
,(22,'Sand process')
,(33,'Paint bedroom')
,(44,'Draw table)
INSERT INTO Material_table (intMaterID,strMaterName,monthlyMatCost)
VALUES (11,'Wood process',200)
,(22,'paint',100)
,(33,'silver',50)
,(44,'unbo',10000)
INSERT INTO Job_table (intJob_ID,intJob_statusID,strJob_Descrip,dteSdate,dteEdate)
VALUES (11,11,'Add Kitchen','02/02/2013','11/01/2015')
,(22,22,'De barn','01/02/2012','12/01/2012')
,(33,33,' Master closet','02/02/2011','02/10/2012')
,(44,11,'bedrooms','03/01/2013','11/01/2013')
INSERT INTO TJob_material (intJob_ID,intMater_ID,intMater_quantity)
VALUES ( 11 , 11 , 11 )
,( 22, 22, 22 )
,( 33 , 33 , 22 )
,( 44 , 44 , 11 )
,( 55 , 55, 11)
INSERT INTO Customer_table(intCus_id,intJob_ID,strFirst_name,strLast_name,strAddre,strCity1,strState1,strZCode)
VALUES (11,11,'dela','truns','11 Main Street','katter','Ottyo','35212')
,(22,22,'Mayla','Janani,'22 Main Street','mery','Ottyo','25223')
INSERT INTO workskillpro (intWorkerID,intIdskill)
VALUES ( 11 , 11 )
,( 22 , 22 )
,( 33 , 33 )
INSERT INTO Job_workertable (intJob_ID,intwork_ID,intTothours)
VALUES ( 11 , 11 , 0)
,( 22, 22 , 50)
,( 33 , 33 , 60)
,( 44, 44, 20)
Project Steps: 1. Database Design 1.1. Design and create a database in third normal form based...
Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587 When all of your queries are complete, cut and paste the SQL Syntax into a word document. In order to see what the column names are, you need to click on the table and then Columns to see the field names. Make sure to include column headings that make sense in the queries (use the as “Field Name” after the field selected). Multi-table Queries...
Create the database and tables
for the database. Show all SQL statements. Include primary and
foreign keys. Insert data into each table. Show select statements
and display the output of each table. Note:Student’s name must be
inserted into table as part of the data! Perform the SQL below:
Query one table and use WHERE to filter the results. The SELECT
clause should have a column list, not an asterisk (*). State the
purpose of the query; show the query and...
Database
Exercise I (50 pts): This exercise deals with a database that stores information about Hotel Management System. Customer (C email, name, country) Payment (Invoice id, C email, payment method, date) invoice (Invoice id, starus, invoice description) Has (Bill id. Invoice id) 9a Bill (Invoice id, Bill id, amount, Bname, type, date, reservation id) Reservation (Hotel id, room id, C email, date, period, reservation id) Rooms(Hotel id. room id, price, category) Hotel (Hotel id. H name. country) Own (room id,...
In Java Create a class Worker. Your Worker class should include the following attributes as String variables: Name, Worker ID, Worker Address, Worker City, Worker State Create the constructor that initializes the above worker attributes. Then make another class name HourlyWorker that inherits from the Worker class. HourlyWOrker has to use the inherited parent class variables and add in hourlySalary and billableHours. Your HourlyWorker class should contain a constructor that calls the constructor from the Worker class to initialize the...
use workbench please
Task 1: Create a database and name it practical2DB. (2
marks)
Task 2: Create all the four tables according to the relational
scheme in Figure 1. (8 marks)
Task 3: Insert 5 records to into each table. (5 marks)
Task 4: Write a query to list alphabetically ordered names,
addresses, and IDs of all the customers whose postcode is in
(40150, 40400, 47500).
(10 marks)
Task 5: Delete 1 record from Products table using their primary
keys....
SQL
I have a database
CREATE TABLE vendor
( vid CHAR(2) NOT NULL,
vname VARCHAR(25) NOT NULL,
PRIMARY KEY (vid) );
CREATE TABLE category
( catid CHAR(2) NOT NULL,
catname VARCHAR(25) NOT NULL,
PRIMARY KEY (catid) );
CREATE TABLE product
( pid CHAR(3) NOT NULL,
pname VARCHAR(25) NOT NULL,
price NUMERIC (7,2) NOT NULL,
vid CHAR(2) NOT NULL,
categoryid CHAR(2) NOT NULL,
PRIMARY KEY (pid));
CREATE TABLE region
( rid CHAR NOT NULL,
rname VARCHAR(25) NOT NULL,
PRIMARY KEY (rid)...
The Case Express Delivery (ED) is a Morgantown based home goods company. Customers can call in orders and ED mails the items to the customer. They also email the customers a bill, as seen below. Customers can mail in a check, once they receive the order. ED needs to track whether the order has been paid or not, but the payment information is handled by a third-party vendor. ED needs to create a database to track their customers. Each customer...
Create an Entity relationship diagram and write a databased design outline for the following: 1. You want to keep track of sales team’s current sales activity. For each salesperson, you want to store unique employee ID, first name, last name, home address information, phone number, and email address. Your customers are typically retails stores and, for each customer, you want to store customer ID, name of business, phone number, address information and salesperson’s information. Also, for each customer, you want...
SQL Homework 1. For each reservation, list the reservation ID, trip ID, customer number, and customer last name. Order the results by customer last name. 2. For each reservation for customer Ryan Goff, list the reservation ID, trip ID, and number of persons. 3. List the trip name of each trip that has Miles Abrams as a guide. 4. List the trip name of each trip that has the type Biking and that has Rita Boyers as a guide. 5....
C# Create an application named JobDemo that declares and uses Job objects. The Job class holds job information for a home repair service. The class has five properties that include: JobNumber - The job number Customer - The customer name Description - The job description Hours - The estimated hours price - The price for the job Create a constructor that requires parameters for all the data except price. Include auto-implemented properties for the job number, customer name, and job...