Question: CREATE TABLE TJobs ( intJobID INTEGER NOT NULL , intCustomerID INTEGER NOT NULL , intStatusID INTEGER NOT NULL , intServiceID INTEGER NOT NULL , dtmStartDate
CREATE TABLE TJobs
intJobID INTEGER NOT NULL
intCustomerID INTEGER NOT NULL
intStatusID INTEGER NOT NULL
intServiceID INTEGER NOT NULL
dtmStartDate DATE NOT NULL
dtmEndDate DATE NOT NULL
strJobDesc VARCHAR NOT NULL
CONSTRAINT TJobsPK PRIMARY KEY intJobID
CREATE TABLE TCustomers
intCustomerID INTEGER NOT NULL
strFirstName VARCHAR NOT NULL
strLastName VARCHAR NOT NULL
strAddress VARCHAR NOT NULL
strCity VARCHAR NOT NULL
intStateID INTEGER NOT NULL
strZip VARCHAR NOT NULL
strPhoneNumber VARCHAR NOT NULL
strEmailAddress VARCHAR NOT NULL
CONSTRAINT TCustomerPK PRIMARY KEY intCustomerID
CREATE TABLE TStatuses
intStatusID INTEGER NOT NULL
strStatus VARCHAR NOT NULL
CONSTRAINT TStatusesPK PRIMARY KEY intStatusID
CREATE TABLE TJobMaterials
intJobMaterialID INTEGER NOT NULL
intJobID INTEGER NOT NULL
intMaterialID INTEGER NOT NULL
intQuantity INTEGER NOT NULL
CONSTRAINT TCustomerJobMaterialsPK PRIMARY KEY intJobMaterialID
CREATE TABLE TMaterials
intMaterialID INTEGER NOT NULL
strDescription VARCHAR NOT NULL
monRetailCost MONEY NOT NULL
monWholeSaleCost MONEY NOT NULL
intVendorID INTEGER NOT NULL
CONSTRAINT TMaterialsPK PRIMARY KEY intMaterialID
CREATE TABLE TVendors
intVendorID INTEGER NOT NULL
strVendorName VARCHAR NOT NULL
strAddress VARCHAR NOT NULL
strCity VARCHAR NOT NULL
intStateID INTEGER NOT NULL
strZip VARCHAR NOT NULL
strPhoneNumber VARCHAR NOT NULL
CONSTRAINT TVendorsPK PRIMARY KEY intVendorID
CREATE TABLE TJobWorkers
intJobWorkerID INTEGER NOT NULL
intJobID INTEGER NOT NULL
intWorkerID INTEGER NOT NULL
intHoursWorked INTEGER NOT NULL
CONSTRAINT TCustomerJobWorkersPK PRIMARY KEY intJobWorkerID
CREATE TABLE TWorkers
intWorkerID INTEGER NOT NULL
strFirstName VARCHAR NOT NULL
strLastName VARCHAR NOT NULL
strAddress VARCHAR NOT NULL
strCity VARCHAR NOT NULL
intStateID INTEGER NOT NULL
strZip VARCHAR NOT NULL
strPhoneNumber VARCHAR NOT NULL
dtmHireDate DATE NOT NULL
dtmTerminationDate DATE NOT NULL
monPayRate MONEY NOT NULL
monBillingRate MONEY NOT NULL
CONSTRAINT TWorkersPK PRIMARY KEY intWorkerID
CREATE TABLE TWorkerSkills
intWorkerSkillID INTEGER NOT NULL
intWorkerID INTEGER NOT NULL
intSkillID INTEGER NOT NULL
CONSTRAINT TWorkerSkillsPK PRIMARY KEY intWorkerSkillID
CREATE TABLE TSkills
intSkillID INTEGER NOT NULL
strSkill VARCHAR NOT NULL
CONSTRAINT TSkillsPK PRIMARY KEY intSkillID
CREATE TABLE TStates
intStateID INTEGER NOT NULL
strState VARCHAR NOT NULL
CONSTRAINT TStatesPK PRIMARY KEY intStateID
CREATE TABLE TServices
intServiceID INTEGER NOT NULL
strService VARCHAR NOT NULL
CONSTRAINT TServicesPK PRIMARY KEY intServiceID
Establish Referential Integrity
# Child Parent Column
TJobs TCustomers intCustomerID
TJobs TStatuses intStatusID
TCustomers TStates intStateID
TJobMaterials TJobs intJobID
TJobMaterials TMaterials intMaterialID
TMaterials TVendors intVendorID
TVendors TStates intStateID
TJobWorkers TJobs intJobID
TJobWorkers TWorkers intWorkerID
TWorkers TStates intStateID
TWorkerSkills TWorkers intWorkerID
TWorkerSkills TSkills intSkillID
TJobs TServices intServiceID
Queries:
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 IDDifficulty Level: #
Write a query to list all complete jobs for Sydney Nye and the materials used on each job. Include the quantity, the individual material cost, and total cost for each material on each job. Order by Job ID and material IDDifficulty Level: #
Write a query to list the total cost for all materials for each completed job for all customers. Difficulty Level: #
Write a query to list First Name, Last Name, and Termination Date of all workers whose employment ended in the and the total jobs they worked on during that year. Difficulty Level: #
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 billing rate. The average hourly billing rate should be weighted based on the number of hours worked at that rate. Difficulty Level: #
Write a query that lists all materials that have not been used on any jobs. Include Material ID and Description. Order by Material IDDifficulty Level: #
Create a query that lists a
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
