A Guide to SQL 10th Edition Mark Shellman - eBook PDF download
A Guide to SQL 10th Edition Mark Shellman - eBook PDF download
https://ebookluna.com/download/a-guide-to-sql-ebook-pdf/
https://ebookluna.com/product/ebook-pdf-a-guide-to-sql-9th-edition-by-
philip-j-pratt/
ebookluna.com
https://ebookluna.com/download/new-perspectives-microsoft-
office-365-access-2019-comprehensive-ebook-pdf/
ebookluna.com
https://ebookluna.com/download/microsoft-sql-server-2016-a-beginners-
guide-ebook-pdf/
ebookluna.com
https://ebookluna.com/download/comptia-security-guide-to-network-
security-fundamentals-ebook-pdf/
ebookluna.com
(eBook PDF) CompTIA A+ Core 1 Exam: Guide to Computing
Infrastructure 10th Edition
https://ebookluna.com/product/ebook-pdf-comptia-a-core-1-exam-guide-
to-computing-infrastructure-10th-edition/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-classical-mythology-10th-by-
mark-morford/
ebookluna.com
https://ebookluna.com/product/original-pdf-havards-nursing-guide-to-
drugs-10th-edition/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-learning-legal-rules-a-
students-guide-to-legal-method-and-reasoning-10th-edition/
ebookluna.com
https://ebookluna.com/download/oca-oracle-database-sql-exam-guide-
exam-1z0-071-ebook-pdf/
ebookluna.com
A GUIDE TO SQL
Tenth Edition
Mark Shellman
Gaston College
Hassan Afyouni, Ed.D.
e-conn Chief Information Officer
Philip J. Pratt
Grand Valley State University
Mary Z. Last
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
This is an electronic version of the print textbook. Due to electronic rights restrictions,
some third party content may be suppressed. Editorial review has deemed that any suppressed
content does not materially affect the overall learning experience. The publisher reserves the right
to remove content from this title at any time if subsequent rights restrictions require it. For
valuable information on pricing, previous editions, changes to current editions, and alternate
formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for
materials in your areas of interest.
Important Notice: Media content referenced within the product description or the product
text may not be available in the eBook version.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
A Guide to SQL, Tenth Edition © 2021, 2015 Cengage Learning, Inc.
Mark Shellman, Hassan Afyouni, WCN: 02-300
Philip J. Pratt, and Mary Z. Last Unless otherwise noted, all content is © Cengage.
SVP, Higher Education Product ALL RIGHTS RESERVED. No part of this work covered by the
Management: Erin Joyner copyright herein may be reproduced or distributed in any form
or by any means, except as permitted by U.S. copyright law,
VP, Product Management: Thais Alencar
without the prior written permission of the copyright owner.
Product Team Manager: Kristin McNary
Microsoft SQL Server is either a registered trademark or
Associate Product Manager: Danielle Klahr
trademark of Microsoft Corporation in the United States and/or
Product Assistants: Anna Goulart and other countries.
Tom Benedetto
MySQL is a registered trademark, and Oracle is a trademark of
Director, Learning Design: Rebecca von Gillern Oracle Corporation.
Senior Manager, Learning Design: Leigh Hefferon
Learning Designer: Emily Pope For product information and technology assistance,
Vice President, Marketing – Science, contact us at Cengage Customer & Sales Support,
1-800-354-9706 or support.cengage.com.
Technology, & Math: Jason Sakos
Marketing Director: Michele McTighe For permission to use material from this text or product,
submit all requests online at
Marketing Manager: Cassie Cloutier www.cengage.com/permissions.
Product Specialist: Mackenzie Paine
Director, Content Creation: Juliet Steiner Library of Congress Control Number: 2020911488
Senior Manager, Content Creation: Patty Stephan
ISBN: 978-0-357-36168-9
Content Manager: Michele Stulga
Developmental Editor: Joy Dark Cengage
200 Pier 4 Boulevard
Director, Digital Production Services: Krista
Boston, MA 02210
Kellman USA
Digital Delivery Lead: Jim Vaughey
Cengage is a leading provider of customized learning solutions
IP Analyst: Ashley Maynard with employees residing in nearly 40 different countries and
IP Project Manager: Carly Belcher sales in more than 125 countries around the world. Find your
Manufacturing Planner: Ron Montgomery local representative at www.cengage.com.
Production Service/Composition: SPi Global Cengage products are represented in Canada by Nelson
Design Director: Jack Pendleton Education, Ltd.
Text Designer: Lizz Anderson To learn more about Cengage platforms and services,
Cover Designer: Joe Devine,Red Hangar Design register or access your online learning solution, or
Cover image: © vs148/ShutterStock.com purchase materials for your course, visit www.cengage.com.
Notice to the Reader contained herein, the reader willingly assumes all risks
Publisher does not warrant or guarantee any of the in connection with such instructions. The publisher
products described herein or perform any independent makes no representations or warranties of any kind,
analysis in connection with any of the product including but not limited to, the warranties of fitness for
information contained herein. Publisher does not particular purpose or merchantability, nor are any such
assume, and expressly disclaims, any obligation to obtain representations implied with respect to the material set
and include information other than that provided to it forth herein, and the publisher takes no responsibility
by the manufacturer. The reader is expressly warned with respect to such material. The publisher shall not
to consider and adopt all safety precautions that might be liable for any special, consequential, or exemplary
be indicated by the activities described herein and to damages resulting, in whole or part, from the readers’
avoid all potential hazards. By following the instructions use of, or reliance upon, this material.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
TA B L E O F C O N T E N T S
Preface ix
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
iv Table of Contents
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Table of Contents v
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
vi Table of Contents
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Table of Contents vii
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
viii Table of Contents
Index I.1
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
P R E FAC E
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
x Preface
D I S T I N G U I S H I N G F E AT U R E S
Use of Examples
Starting in Module 3, each module contains multiple examples that use SQL to solve a
problem. Following each example, students will read about the commands that are used to
solve the stated problem, and then they will see the SQL commands used to arrive at the
solution. For most students, learning through examples is the most effective way to master
material. For this reason, instructors should encourage students to read the modules at
the computer and input the commands shown in the figures.
Case Studies
A running case study—KimTay Pet Supplies—is presented in all the examples within the
modules and in the first set of exercises at the end of each module. Although the data-
base is small in order to be manageable, the examples and exercises for the KimTay Pet
Supplies database simulate what a real business can accomplish using SQL commands.
Using the same case study as examples within the module and in the end-of-module exer-
cises ensures a high level of continuity to reinforce learning.
A second case study—the StayWell Student Accommodation database—is used in
a second set of exercises at the end of each module. This case study gives students a
chance to venture out “on their own” without the direct guidance of examples from
the text.
Helpful Hints
Helpful Hint boxes call out fundamental information and provide useful tips for the
successful implementation of SQL. Students should pay careful attention to the advice
within Helpful Hint boxes and are encouraged to review the hints as they are practicing
SQL skills.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xi
Review Material
A Summary and Key Terms list appear at the end of each module, followed by Review
Questions that test students’ recall of the important points in the module and occasionally
test their ability to apply what they have learned. Critical Thinking questions that
reinforce problem-solving and analytical skills are included for review questions and
hands-on exercises. Each module also contains exercises related to the KimTay Pet
Supplies and StayWell Student Accommodation databases.
Appendices
Three appendices appear at the end of this text. Appendix A is an SQL reference that
describes the purpose and syntax for the major SQL commands featured in the text.
Students can use Appendix A to identify how and when to use important commands
quickly. The SQL reference appendix contains references to specific pages in the
text where the command is discussed to make it easy for students to find additional
information when they need to refer back to the section in the text where the topic is
covered.
Appendix B includes a “How Do I” reference, which lets students cross-reference the
appropriate section in Appendix A by searching for the answer to a question. Appendix C
is the 10 Commandments of Writing Queries. This appendix presents summarized steps
and rules for composing an SQL statement.
Instructor Support
The Tenth Edition includes a package of proven supplements for instructors and
students. The Instructor’s Resources offer a detailed electronic Instructor’s Manual,
figure files, Microsoft® PowerPoint® presentations, and the Cognero Test Bank. The
Instructor’s Manual includes suggestions and strategies for using this text as well as
answers to Review Questions and solutions to the end-of-module exercises. Figure files
allow instructors to create their own presentations using figures appearing in the text.
Instructors can also take advantage of lecture presentations provided on PowerPoint
slides; these presentations follow each module’s coverage precisely, include module
figures, and can be customized.
The Instructor’s Resources include the KimTay Pet Supplies and StayWell Student
Accommodation cases script files to create the tables and data in these databases in
MySQL, Oracle, and SQL Server. These files are provided so instructors have the choice of
assigning exercises in which students create the databases used in this text and load them
with data, or they can provide the MySQL, Oracle, or SQL Server script files to students to
automate and simplify these tasks.
O R G A N I Z AT I O N O F T H E T E X T
The text contains eight modules and three appendices, which are described in the follow-
ing sections.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xii Preface
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xiii
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xiv Preface
Embedded Questions
In many places, you’ll find Q&A sections to ensure that you understand some crucial
material before you proceed. In some cases, the questions are designed to give you the
chance to consider some special concept in advance of its actual presentation. In all cases,
the answer to each question appears immediately after the question. You can simply read
the question and its answer, but you will benefit from taking time to determine the answer
to the question before checking your answer against the one given in the text.
End-of-Module Material
The end-of-module material consists of a Summary, a Key Terms list, Review Questions,
Critical Thinking questions, and exercises for the KimTay Pet Supplies and StayWell
Student Accommodation databases. The Summary briefly describes the material covered
in the module. The Review Questions require you to recall and apply the important mate-
rial in the module. The KimTay Pet Supplies and StayWell Student Accommodation exer-
cises test your knowledge of the module material; your instructor will assign one or more
of these exercises for you to complete. Critical-thinking questions that reinforce problem-
solving and analytical skills are included for review questions and hands-on exercises.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
A B O U T T H E AU T H O R S
Mary Z. Last
Mary Z. Last has taught computer information systems since 1984. She retired from
the University of Mary Hardin-Baylor, Belton, Texas, where she was an associate profes-
sor and the Director of the Center for Effectiveness in Learning and Teaching. Ms. Last is
actively involved in the Computing Educator’s Oral History Project that encourages young
women to pursue careers in math and science. She has been a contributing author to the
Shelly Cashman Series since 1992. She also authors many instructor resources for leading
database texts.
ACKNOWLEDGMENTS
From Mark Shellman:
I would first like to dedicate this text to the memory of parents, Mickey and Shelba
Shellman, that passed away during the writing of this text. No child has ever been more
loved and supported in their life than I. I would also like to thank my wife Donna Sue, and
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xvi About the Authors
children, Taylor and Kimberly, for their support and patience during this project. Last,
but certainly not least, I would like to thank the entire development team of Amy Savino,
Michele Stulga, and Joy Dark, along with my co-author Hassan Afyouni. Thank you all
from the bottom of my heart for all of your support and caring during this project. It
means more than you will ever know. You are truly the best!
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
MODULE 1
INTRODUCTION TO
KIMTAY PET SUPPLIES
AND STAYWELL STUDENT
ACCOMMODATION DATABASES
OBJECTIVES
INTRODUCTION
In this module, you examine the database requirements of KimTay Pet Supplies—a
company that is used in the examples throughout the text. Then, you examine the
database requirements for StayWell, whose database is featured in the exercises that
appear at the end of each module.
WHAT IS A DATABASE?
Throughout this text, you will work with databases for two organizations: KimTay Pet
Supplies and StayWell. A database is a structure that contains different categories
of information and the relationships between these categories. For example, the
KimTay Pet Supplies database contains information about categories such as sales
representatives (sales reps), customers, invoices, and items. The StayWell database
contains information about the offices that manage the accommodation, the owners
of the accommodation, the residents, and the services (such as cleaning and
maintenance) offered for the properties.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2 Module 1
Each database also contains relationships between categories. For example, the
KimTay Pet Supplies database contains information that relates sales reps to the
customers they represent and customers to the invoices they have placed. The StayWell
database contains information that relates the two main company offices to the properties
that they manage, the owners, the different services to the service request, and to the
resident renting a property.
As you work through the modules in this text, you will learn more about these
databases and how to view and update the information they contain. As you read each
module, you will see examples from the KimTay Pet Supplies database. At the end of
each module, your instructor might assign the exercises for the KimTay Pet Supplies or
StayWell databases.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Introduction to KimTay Pet Supplies and StayWell Student Accommodation Databases 3
Extensions
Body
KimTay Pet Supplies also must store the following items in the database for each
customer’s invoice:
• The invoice number, the date the invoice was placed, and the ID of the
customer that placed the invoice. The customer’s name, full address, and
the ID of the sales rep who represents the customer are stored with the
customer information. The name of the sales rep is stored with the sales
rep information.
• The invoice number, the item ID, the quantity ordered, and the quoted price
for each invoice line. The item description is stored with the information
about items. The result of multiplying the number of units ordered by the
quoted price is not stored because the database can calculate it when needed.
The overall invoice total is not stored. Instead, the database calculates the total
whenever an invoice is printed or displayed on the screen.
Figure 1-2 shows sample data for KimTay Pet Supplies.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
4 Module 1
CUSTOMER
CUST_ FIRST_ LAST_ ADDRESS CITY STATE POSTAL EMAIL BALANCE CREDIT_ REP_
ID NAME NAME LIMIT ID
126 Joey Smith 17 Fourth St Cody WY 82414 jsmith17@ $80.68 $500.00 05
example.com
182 Billy Rufton 21 Simple Cir Garland WY 82435 billyruff@ $43.13 $750.00 10
example.com
227 Sandra Pincher 53 Verde Ln Powell WY 82440 spinch2@ $156.38 $500.00 15
example.com
294 Samantha Smith 14 Rock Ln Ralston WY 82440 ssmith5@ $58.60 $500.00 10
example.com
314 Tom Rascal 1 Rascal Farm Cody WY 82414 trascal3@ $17.25 $250.00 15
Rd example.com
375 Melanie Jackson 42 Blackwater Elk Butte WY 82433 mjackson5@ $252.25 $250.00 05
Way example.com
435 James Gonzalez 16 Rockway Rd Wapiti WY 82450 jgonzo@ $230.40 $1,000.00 15
example.com
492 Elmer Jackson 22 Jackson Garland WY 82435 ejackson4@ $45.20 $500.00 10
Farm Rd example.com
543 Angie Hendricks 27 Locklear Ln Powell WY 82440 ahendricks7@ $315.00 $750.00 05
example.com
616 Sally Cruz 199 18th Ave Ralston WY 82440 scruz5@ $8.33 $500.00 15
example.com
721 Leslie Smith 123 Sheepland Elk Butte WY 82433 lsmith12@ $166.65 $1,000.00 10
Rd example.com
795 Randy Blacksmith 75 Stream Rd Cody WY 82414 rblacksmith6@ $61.50 $500.00 05
example.com
SALES_REP
REP_ID FIRST_NAME LAST_NAME ADDRESS CITY STATE POSTAL CELL_PHONE COMMISSION RATE
ITEM
ITEM_ID DESCRIPTION ON_HAND CATEGORY LOCATION PRICE
AD72 Dog Feeding Station 12 DOG B $79.99
BC33 Feathers Bird Cage (12×24×18) 10 BRD B $79.99
CA75 Enclosed Cat Litter Station 15 CAT C $39.99
DT12 Dog Toy Gift Set 27 DOG B $39.99
FM23 Fly Mask with Ears 41 HOR C $24.95
FS39 Folding Saddle Stand 12 HOR C $39.99
FS42 Aquarium (55 Gallon) 5 FSH A $124.99
KH81 Wild Bird Food (25 lb) 24 BRD C $19.99
LD14 Locking Small Dog Door 14 DOG A $49.99
LP73 Large Pet Carrier 23 DOG B $59.99
PF19 Pump & Filter Kit 5 FSH A $74.99
QB92 Quilted Stable Blanket 32 HOR C $119.99
SP91 Small Pet Carrier 18 CAT B $39.99
UF39 Underground Fence System 7 DOG A $199.99
WB49 Insulated Water Bucket 34 HOR C $79.99
FIGURE
INVOICES1-2 Sample data for KimTay INVOICE_LINE
Pet Supplies
INVOICE_NUM INVOICE_DATE CUST_ID INVOICE_NUM ITEM_ID QUANTITY QUOTED_PRICE
14216 11/15/2021 125 14216 CA75 3 $37.99
14219 11/15/2021 227 14219 AD72 2 $79.99
14222 11/16/2021 294 14219 DT12 4 $39.99
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
14224
Editorial review has deemed 11/16/2021
that any suppressed content does not materially182
affect the overall learning
14222experience. CengageLD14 $47.99
Learning reserves the right to1remove additional content at any time if subsequent rights restrictions require it.
PF19 Pump & Filter Kit 5 FSH A $74.99
QB92 Quilted Stable Blanket 32 HOR C $119.99
SP91 Small Pet Carrier 18 CAT B $39.99
UF39 Introduction
Underground to KimTay
Fence System Pet Supplies
7 and StayWell
DOG A Student Accommodation
$199.99 Databases 5
WB49 Insulated Water Bucket 34 HOR C $79.99
INVOICES INVOICE_LINE
INVOICE_NUM INVOICE_DATE CUST_ID INVOICE_NUM ITEM_ID QUANTITY QUOTED_PRICE
14216 11/15/2021 125 14216 CA75 3 $37.99
14219 11/15/2021 227 14219 AD72 2 $79.99
14222 11/16/2021 294 14219 DT12 4 $39.99
14224 11/16/2021 182 14222 LD14 1 $47.99
14228 11/18/2021 435 14224 KH81 4 $18.99
14231 11/18/2021 125 14228 FS42 1 $124.99
14233 11/18/2021 435 14228 PF19 1 $74.99
14237 11/19/2021 616 14231 UF39 2 $189.99
14233 KH81 1 $19.99
14233 QB92 4 $109.95
In the SALES_REP table, you see that there are four reps, whose ID values are
05, 10, 15, and 20. The name of sales rep 05 is Susan Garcia. Her street address is
42 Mountain Ln. She lives in Cody, WY, and her postal code is 82414. Her cell phone
number is 307-824-1245. Her total commission is $12,743.16, and her commission rate
is 0.04 (four percent).
In the CUSTOMER table, 12 KimTay Pet Supplies customers are identified with
the ID values of 126, 182, 227, 294, 314, 375, 435, 492, 543, 616, 721, and 795. The
name of customer number 126 is Joey Smith. This customer’s address is 17 Fourth St in
Cody, WY, with a postal code of 82414. The e-mail address of the customer is jsmith17@
example.com. The customer’s current balance is $80.68, and their credit limit is $500.00.
The value 05 in the REP_ID column indicates that Joey Smith is represented by sales rep
05 (Susan Garcia).
In the table named ITEM, you see that there are 15 items, whose item ID values are
AD72, BC33, CA75, DT12, FM23, FS39, FS42, KH81, LD14, LP73, PF19, QB92, SP91,
UF39, and WB49. Item AD72 is a Dog Feeding Station, and KimTay Pet Supplies has
12 units of this item on hand. The Dog Feeding Station item is in the DOG category, and it
is located in area B. The price of the Dog Feeding Station is $79.99. Other categories are
BRD (bird), CAT, FSH (fish), and HOR (horse).
In the table named INVOICES, you see that there are eight invoices which are
identified with the numbers 14216, 14219, 14222, 14224, 14228, 14231, 14233, and
14237. Invoice number 14216 was placed on November 15, 2021, by customer 125
(Joey Smith).
The table named INVOICE_LINE might seem strange at first glance. Why do you
need a separate table for the invoice lines? Could they be included in the INVOICES
table? The answer is technically yes. You could structure the table named INVOICES
as shown in Figure 1-3. Notice that this table contains the same invoices as shown in
Figure 1-2, with the same dates and customer ID numbers. In addition, each table row in
Figure 1-3 contains all the invoice lines for a given invoice. Examining the second row,
for example, you see that invoice 14219 has two invoice lines. One of the invoice lines is
for 2 units of item AD72 at $79.99 each, and the other invoice line is for 4 units of item
DT12 at $39.99 each.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
6 Module 1
Q&A
Question: How is the information from Figure 1-2 represented in Figure 1-3?
Answer: Examine the INVOICE_LINE table shown in Figure 1-2 and note the second and third rows.
The second row indicates that there is an invoice line on invoice 14219 for 2 units of item AD72 at
$79.99 each. The third row indicates that there is an invoice line on invoice 14219 for 4 units of item
DT12 at $39.99 each. Thus, the information that you find in Figure 1-3 is represented in Figure 1-2 in
two separate rows rather than in one row.
It might seem inefficient to use two rows to store information that could be rep-
resented in one row. There is a problem, however, with the arrangement shown in
Figure 1-3—the table is more complicated. In Figure 1-2, there is a single entry at each
INVOICES
INVOICE_NUM INVOICE_DATE CUST_ID ITEM_ID QUANTITY QUOTED_PRICE
location in the table. In Figure 1-3, some of the individual positions within the table
contain multiple entries, making it difficult to track the information between columns.
In the row for invoice number 14219, for example, it is crucial to know that the AD72
corresponds to the 2 in the QUANTITY column (not to the 4) and that it corresponds
to the $79.99 in the QUOTED_PRICE column (not to the $39.99). In addition, a more
complex table raises practical issues, such as the following:
• How much room do you allow for these multiple entries?
• What happens when an invoice has more invoice lines than you have allowed
room for?
• For a given item, how do you determine which invoices contain invoice lines
for that item?
Although none of these problems is unsolvable, they do add a level of complexity that
is not present in the arrangement shown in Figure 1-2. In Figure 1-2, there are no multiple
entries to worry about, it does not matter how many invoice lines exist for any invoice,
and finding every invoice that contains an invoice line for a given item is easy (just look
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Introduction to KimTay Pet Supplies and StayWell Student Accommodation Databases 7
for all invoice lines with the given item number in the ITEM_ID column). In general, this
simpler structure is preferable, and that is why invoice lines appear in a separate table.
To test your understanding of the KimTay Pet Supplies data, use Figure 1-2 to answer
the following questions.
Q&A
Question: What are the customer ID values of the customers represented by Susan Garcia?
Answer: 125, 375, 543, and 795. (Look up the REP_ID value of Susan Garcia in the SALES_REP table
and obtain the value 05. Then find all customers in the CUSTOMER table that have the value 05 in the
REP_ID field.)
Q&A
Question: What is the name of the customer that placed invoice 14222, and what is the name of the
sales rep who represents the customer?
Answer: Samantha Smith is the customer, and Richard Miller is the sales rep. (Look up the CUST_ID
value in the INVOICES table for invoice 14222 and obtain the ID value 294. Then find the customer
in the CUSTOMER table with the CUST_ID value of 294. Using the REP_ID value, which is 10,
find the name of the sales rep in the SALES_REP table.)
Q&A
Question: List all items that appear in invoice 14228. For each item, give the description, quantity
ordered, and quoted price.
Answer: Item ID: FS42; description: Aquarium (55 Gallon); quantity ordered: 1; and quoted
price: $124.99. Also, item ID: PF19; description: Pump & Filter Kit; quantity ordered: 1; and quoted
price: $74.99. (Look up each INVOICE_LINE table row on which the invoice number is 14228.
Each of these rows contains an item ID, quantity ordered, and quoted price. Use the item ID to look up
the corresponding item description in the ITEM table.)
Q&A
Question: Why is the QUOTED_PRICE column in the INVOICE_LINE table? Can’t you just use the
item ID and look up the price in the ITEM table?
Answer: If the QUOTED_PRICE column did not appear in the INVOICE_LINE table, you would need
to obtain the price for an item on an invoice line by looking up the price in the ITEM table. Although
this approach is reasonable, it prevents KimTay Pet Supplies from charging different prices to different
customers for the same item. Because KimTay Pet Supplies wants the flexibility to quote and charge
different prices to different customers, the QUOTED_PRICE column is included in the INVOICE_LINE
table. If you examine the INVOICE_LINE table, you will see cases in which the quoted price matches
the actual price in the ITEM table, and cases in which it differs. For example, in invoice number 14216,
Joey Smith bought three Enclosed Cat Litter Stations, and KimTay Pet Supplies charged only $37.99
each, not the regular price of $39.99.
Copyright 2021 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Other documents randomly have
different content
Ja samalla kuin hänen pienet harmaat silmänsä äkkiä välähtivät
kuin metsästyskoiran silmät, hän osotti minulle kahta arvoisaa
olentoa, jotka juuri kohosivat näkyviin Valérien-vuoren rinteellä.
"Kyllä minä menen", sanoi äiti; ja kun mies teki kaikki mitä vaimo
tahtoi, niin hän nytkin lähti liikkeelle ja kulki piiripäällikön,
pormestarin, esikunnan ja komisariuksen luona, pelosta hikoillen,
vilusta jähmettyen, tunkeutuen kaikkialle, erehtyen ovissa, viipyen
pari tuntia ihmisjonossa jonkun viraston edessä huomatakseen sitten
ettei se ollutkaan oikea paikka. Vihdoinkin hän palajaa iltasella
taskussaan kuvernöörin lupakirja… Huomenna he nousevat ajoissa
aamukylmään ja sytyttävät lampun. Mies pureksii lämpimikseen
leipäkyrsää, mutta vaimolla ei ole nälkä. Hän tahtoo mieluummin
murkinoida poikansa kera vuorella. Ja ravitakseen kerrankin oikein
ruhtinaallisesti nostomies parkaa hän latoo kaislakoriin aika kasan
piiritykseltä säästyneitä ruokatavaroita, suklaatia, makeisia, vanhaa
viiniä y.m. kahdeksan frangin arvoiseen säilykerasiaan saakka, jota
oli talletettu huolellisesti suurimman puutteen varalle. Sitten
lähdetään. Kun he saapuvat kaupungin muurin luo, on heidän
päästävä portista ulos. Heidän täytyy näyttää lupakirja. Vaimoa
pelottaa jo kovasti… Mutta ei hätää! Lupakirja on laillisessa
kunnossa.
*****
Se oli hän!
"Päivää, äitiseni."
Maalaiset Pariisissa.
Piirityksen aikana.
*****
He ovat nyt Pariisissa. Asuntona on heillä kaksi huonetta
neljännessä kerroksessa kolkon kadun varrella… Miehellä ei ole
suurtakaan hätää. Hänelle on keksitty sopivaa työtä; hän näet
kuuluu kansalliskaartiin, hän oleksii varustuksilla ja harjoituksissa ja
touhuaa parhaansa mukaan unohtaakseen tyhjän aittansa ja
kylvämättömän niittynsä. Vaimo, ollen arempaa luonnetta, on
huolissaan, ikävöi eikä tiedä mitä tehdä. Hän on pannut kaksi
vanhinta tyttöänsä kouluun, ja kolkossa puutarhattomassa
koulutalossa nuo tytöntypykät tuntevat tukehtuvansa muistellessaan
hauskaa maalaista luostarikoulua, joka pörisi iloisesti kuin
mehiläispesä, ja puolen peninkulman matkaa, joka oli tehtävä
metsän halki joka aamu kouluun mennessä. Äiti kärsii nähdessään
heidät alakuloisina, mutta varsinkin pikku poikanen tekee hänet
levottomaksi.
Ranskan keijukaiset.
Kuviteltu jutelma.
"Mélusine."
"Kuinka sanoitte?"…
"Mélusine."
"Ikänne?"
"Ammattinne?"
"Olen keijukainen!…"
Ritarimerkki.
Kuvastin.
Updated editions will replace the previous one—the old editions will
be renamed.