misconduct policy.

Page 1 of 5
Database Design and Development
Homework 3
Create the SQL query as requested for each question. Be certain to follow the formatting illustrated in each
question and use column aliases as shown. Note that you are provided with sample data only. The data you are
using is static – it is not being updated by the users as parts are scheduled and jobs completed.
• The assignment is individual effort only. You cannot talk to each other or anyone else regarding the
problems except the instructor. Collaborating with anyone else in any way is a violation of the class
academic misconduct policy.
• NO CREDIT will be given for code that:
o Is developed using a tool other than SQL Server Management Studio (SSMS)
o Is not developed in your assigned database
o Uses functions, keywords, or techniques not covered in this class (The assignment is a test of your
mastery of the material we covered in class. Check the NOT ALLOWED LIST in D2L for common
mistakes.)
o Queries that return an error when executed
o Queries that contain a Cartesian product (watch the video about Cartesian products)
o Queries that contain a subquery anywhere other than FROM or WHERE.
• All queries must be terminated with a semicolon.
• Do not use unnecessary subqueries.
• Submission is to be made through Desire2Learn (D2L). Upload your submission with a .sql extension (do
NOT put it in an MS Word document) to the Take Home Test 3 dropbox in D2L.
• You must create a MAG schema in your database and copy the tables into the MAG schema of your
database from the MAG schema of the STARTERDB database. Do NOT make up your own tables or make
up your own data – only use the table structures and data that already exist on our server.
• Be certain to use the column aliases and formats illustrated in the sample output shown for
each problem.
• Use comments (either a double dash – – or a block comment /* */) to number your answers
with the appropriate question number. You do not need to re-write the question. Do not start
your answer on the same line as the comment that numbers the answer.
• Use a comment at the beginning of the text file to include your name in the file. Nothing but
your name should be on the first line (e.g., –John Smith). (Hint: your name does not start with
“Name:”)
• Remove all extra commands (like SELECT * FROM MAG.JOB;) that you used as you were crafting
your answers. Points will be deducted for extra commands left in the file.
• Only submit one query per question. If there is more than one query for a question, then only
the first query will be evaluated.Page 2 of 5
Manufacturing Athletic Gear (MAG) is a company that produces a variety of exercise bicycles and
other fitness equipment. You are writing queries that will form the basis of several reports that the
users have requested from the system. The data that you will be working with is a small subset of the
data that were generated for use while developing and testing the system. Your queries must match
the requirements given to ensure that correct results will be produced when applied to the full set of
live data.
MAG ERD
Explanation of the data model:
The WORKER table contains data on some of the people that work at MAG. All of the workers in this
system are manufacturing workers that produce parts for the products that MAG sells. The PART table
contains data on the parts produced by MAG. Product production is planned based on customer
demand data (not included in this data model). A production manager will evaluate the demand data
and determine which products need to be assembled on which dates and in what quantities (not
included in this data model). Based on the products that need to be produced, parts are scheduled for
production. The SCHEDULE table contains data on the parts that need to be produced, what date the
parts will be needed, and an estimate on how many will be needed (sch_plan_qty). After the production
run that uses these parts is finished, the actual number of each part used (sch_actual_qty) is entered.
Based on the upcoming demand for scheduled parts, the shop manager will assign workers to produce
specific parts. The EQUIPMENT table contains data on the manufacturing equipment used to produce
the parts. The JOB table contains data on which worker produces which part on which equipment.Page 3 of 5
For each of the following questions, write the SELECT query that would return the results requested. Be
certain to use the column aliases and formats illustrated in the sample output shown for each problem.
0. Create the MAG schema in your database. Copy the above tables into your MAG schema from
the MAG schema in the STARTERDB database. You MUST name your tables exactly the same
(pay close attention for typos) as those given in the ERD. No points are associated with this
problem specifically, but if it isn’t right none of your code will work in my database and you’ll
end up with a zero on the homework.
1. Write a query to display the worker’s last name, equipment number, equipment type, job date,
the total cost for that job, and the quantity of parts produced in that job. The total cost is the
labor cost plus the equipment cost, where the labor cost is the worker’s wage multiplied by the
hours that the job ran. The equipment cost is the equipment startup cost plus the run cost. The
run cost is the hourly run cost for the equipment multiplied by the hours that the job ran. Limit
the results to only jobs with a total cost greater than $200 and that produced fewer than 300
parts. Sort the results by the total cost in descending order then by the quantity produced in
ascending order.
Result:
2. Write a query to display the worker number, last name and first name for all machinists that
have never completed a job using any type of “welder” equipment. Sort the results by worker
last name and then first name, both in ascending order.
Result:Page 4 of 5
3. Write a query to display the equipment number, type and operating cost for a 1-hour run, a 4-
hour run, and an 8-hour run for each piece of equipment. The operating cost is the startup cost
for the equipment plus the run cost. The run cost is the hourly run cost for the equipment
multiplied by the number of hours the equipment will be running. Limit the results to only
equipment that is a Manual Press, Reamer, or Arc Welder. Sort the results by the equipment
type in ascending order, and then by the 1-hour operating cost in ascending order.
Result:
4. Write a query to display the worker name (first and last names separated with a single space),
part description, average labor cost per unit, and times produced. The average labor cost per
unit is the calculated by averaging the labor cost per unit for all jobs in which that worker
produced that part. The labor cost per unit for a job is calculated as the worker’s hourly wage
multiplied by the number of hours that a job ran, divided by the quantity of the part produced
during that job. The number of times produced is simply the number of jobs in which that
worker produced that part. Limit the results to only ones where the times produced is greater
than 2. Sort the result by the average labor cost per unit in ascending order.
Result:
5. Write a query to display the worker number, last name, and first name of the worker that
worked the longest job ever run on a reamer.
Result:Page 5 of 5
Checklist:
• Does your output match the result output exactly (column aliases, rounding, sorting, etc.)?
• Avoid these common mistakes:
o Using LIKE when all you need is “=”
o Using LIKE without a wildcard
o Using a Cartesian product
o Using a subquery when it is not needed
o Using a subquery anywhere other than FROM or WHERE
o Including unnecessary tables in a query
o Using outer joins when only inner joins are needed
o Using functions, keywords, or techniques not covered in this class (Check the Not
Allowed List in D2L for some common SQL functions and techniques that you might have
seen on the Internet that are NOT covered in this class. The list is not exhaustive, but it
covers the disallowed things that I see the most often.)
• Did you put your name in a comment at the top of your file? Nothing but your name in the
comment?
• Did you number your answers using comments?
• Did you include the commands to copy the tables into the MAG schema (Question 0)?
• Did you remove all extra commands (the only commands should be commands for question 0
and five SELECT queries)?
• Did you remember to end your filename with .sql?
• Did you remember to upload your submission to the Homework 3 dropbox?
• Did you logout of D2L then log back in and go to the dropbox to open your submission and verify
that you uploaded the correct file

Fountain Writers
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.