100% found this document useful (1 vote)
75 views30 pages

Oracle 12c SQL 3rd Edition (Ebook PDF) PDF Download

The document provides information on the installation and download of the eBook 'Oracle 12c SQL 3rd Edition' by Joan Casteel, along with links to various other SQL-related eBooks available on ebookluna.com. It includes a detailed table of contents outlining chapters on database concepts, SQL statements, table management, constraints, data manipulation, and more. The content is structured to facilitate learning with summaries, review questions, and hands-on assignments for each chapter.

Uploaded by

shemopranozx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
75 views30 pages

Oracle 12c SQL 3rd Edition (Ebook PDF) PDF Download

The document provides information on the installation and download of the eBook 'Oracle 12c SQL 3rd Edition' by Joan Casteel, along with links to various other SQL-related eBooks available on ebookluna.com. It includes a detailed table of contents outlining chapters on database concepts, SQL statements, table management, constraints, data manipulation, and more. The content is structured to facilitate learning with summaries, review questions, and hands-on assignments for each chapter.

Uploaded by

shemopranozx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Oracle 12c SQL 3rd Edition (eBook PDF) install

download

https://ebookluna.com/product/oracle-12c-sql-3rd-edition-ebook-
pdf/

Download more ebook from https://ebookluna.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

(eBook PDF) Oracle 12c SQL 3rd Edition by Joan Casteel

https://ebookluna.com/product/ebook-pdf-oracle-12c-sql-3rd-edition-by-
joan-casteel/

ebookluna.com

Oracle SOA Suite 12c handbook 1st Edition Jellema - eBook


PDF

https://ebookluna.com/download/oracle-soa-suite-12c-handbook-ebook-
pdf/

ebookluna.com

OCA Oracle Database SQL Exam Guide (Exam 1Z0-071) 1st


Edition Steve O’Hearn - eBook PDF

https://ebookluna.com/download/oca-oracle-database-sql-exam-guide-
exam-1z0-071-ebook-pdf/

ebookluna.com

Progress in Heterocyclic Chemistry Volume 29 1st Edition -


eBook PDF

https://ebookluna.com/download/progress-in-heterocyclic-chemistry-
ebook-pdf/

ebookluna.com
(eBook PDF) Translational Medicine in CNS Drug
Development, Volume 29

https://ebookluna.com/product/ebook-pdf-translational-medicine-in-cns-
drug-development-volume-29/

ebookluna.com

A Guide to SQL 10th Edition Mark Shellman - eBook PDF

https://ebookluna.com/download/a-guide-to-sql-ebook-pdf/

ebookluna.com

(eBook PDF) A Guide to SQL 9th Edition by Philip J. Pratt

https://ebookluna.com/product/ebook-pdf-a-guide-to-sql-9th-edition-by-
philip-j-pratt/

ebookluna.com

SQL Server 2022 Administration Inside Out 1st Edition


Randolph West - eBook PDF

https://ebookluna.com/download/sql-server-2022-administration-inside-
out-ebook-pdf/

ebookluna.com

Microsoft SQL Server 2016 a beginner's guide Sixth Edition


Petkovic - eBook PDF

https://ebookluna.com/download/microsoft-sql-server-2016-a-beginners-
guide-ebook-pdf/

ebookluna.com
TABLE OF CONTENTS

Preface xiv
Chapter 1 Overview of Database Concepts 1
Introduction 2
Database Terminology 2
Database Management System 3
Database Design 4
Entity-Relationship (E-R) Model 5
Database Normalization 6
Relating Tables in the Database 10
Structured Query Language (SQL) 12
Databases Used in This Textbook 13
Basic Assumptions 13
Tables in the JustLee Books Database 14
Topic Sequence 16
Software Used in This Textbook 16
Chapter Summary 17
Review Questions 17
Multiple Choice 18
Hands-On Assignments 21
Advanced Challenge 22
Case Study: City Jail 22

Chapter 2 Basic SQL SELECT Statements 25


Introduction 26
Creating the JustLee Books Database 27
SELECT Statement Syntax 30
Selecting All Data in a Table 31
Selecting One Column from a Table 33
Selecting Multiple Columns from a Table 34
Operations in the SELECT Statement 36
Using Column Aliases 36
Using Arithmetic Operations 39
NULL Values 40
Using DISTINCT and UNIQUE 42
Using Concatenation 44
Chapter Summary 49
Chapter 2 Syntax Summary 49

Copyright 2016 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.
Review Questions 50
Multiple Choice 51
Hands-On Assignments 54
Advanced Challenge 55
Case Study: City Jail 55

Chapter 3 Table Creation and Management 57


Introduction 58
Table Design 59
Table Creation 63
Defining Columns 63
Viewing a List of Tables: USER_TABLES 65
Viewing Table Structures: DESCRIBE 66
Table Creation with Subqueries 70
CREATE TABLE … AS Command 70
Modifying Existing Tables 72
ALTER TABLE … ADD Command 73
ALTER TABLE … MODIFY Command 74
ALTER TABLE … DROP COLUMN Command 79
ALTER TABLE … SET UNUSED/DROP UNUSED COLUMNS Command 80
Renaming a Table 83
Truncating a Table 85
Deleting a Table 86
Chapter Summary 91
Chapter 3 Syntax Summary 92
Review Questions 93
Multiple Choice 94
Hands-On Assignments 97
Advanced Challenge 97
Case Study: City Jail 98

Chapter 4 Constraints 103


Introduction 104
Creating Constraints 105
Creating Constraints at the Column Level 106
Creating Constraints at the Table Level 106
Using the PRIMARY KEY Constraint 107
Using the FOREIGN KEY Constraint 110
Using the UNIQUE Constraint 115
Using the CHECK Constraint 116
Using the NOT NULL Constraint 119
Including Constraints During Table Creation 121
Adding Multiple Constraints on a Single Column 125
Viewing Constraint Information 126

vi Table of Contents

Copyright 2016 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.
Disabling and Dropping Constraints 128
Using DISABLE/ENABLE 128
Dropping Constraints 129
Chapter Summary 131
Chapter 4 Syntax Summary 131
Review Questions 133
Multiple Choice 134
Hands-On Assignments 137
Advanced Challenge 139
Case Study: City Jail 139

Chapter 5 Data Manipulation and Transaction Control 141


Introduction 142
Inserting New Rows 143
Using the INSERT Command 143
Handling Virtual Columns 150
Handling Single Quotes in an INSERT Value 152
Inserting Data from an Existing Table 154
Modifying Existing Rows 156
Using the UPDATE Command 156
Using Substitution Variables 158
Deleting Rows 162
Using Transaction Control Statements 163
COMMIT and ROLLBACK Commands 164
SAVEPOINT Command 165
Using Table Locks 168
LOCK TABLE Command 168
SELECT … FOR UPDATE Command 169
Chapter Summary 171
Chapter 5 Syntax Summary 172
Review Questions 173
Multiple Choice 173
Hands-On Assignments 176
Advanced Challenge 177
Case Study: City Jail 178

Chapter 6 Additional Database Objects 181


Introduction 182
Sequences 183
Creating a Sequence 184
Using Sequence Values 189
Setting and Altering Sequence Definitions 192
Altering Sequence Definitions 194
Removing a Sequence 196
Use Identity Columns Instead of Sequences for Primary Key Columns 197

Table of Contents vii

Copyright 2016 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.
Indexes 199
B-Tree Indexes 200
Bitmap Indexes 206
Function-Based Indexes 208
Index Organized Tables 209
Verifying an Index 210
Altering or Removing an Index 211
Synonyms 212
Deleting a Synonym 215
Chapter Summary 216
Chapter 6 Syntax Summary 217
Review Questions 218
Multiple Choice 219
Hands-On Assignments 222
Advanced Challenge 223
Case Study: City Jail 224

Chapter 7 User Creation and Management 225


Introduction 226
Data Security 227
Creating a User 228
Creating Usernames and Passwords 228
Assigning User Privileges 230
System Privileges 230
Granting System Privileges 231
Object Privileges 232
Granting Object Privileges 232
Managing Passwords 236
Using Roles 237
Creating and Assigning Roles 238
Using Predefined Roles 240
Using Default Roles 241
Enabling Roles After Login 242
Viewing Privilege Information 242
Removing Privileges and Users 244
Revoking Privileges and Roles 244
Dropping a Role 246
Dropping a User 246
Chapter Summary 247
Chapter 7 Syntax Summary 247
Review Questions 249
Multiple Choice 249
Hands-On Assignments 253
Advanced Challenge 253
Case Study: City Jail 254

viii Table of Contents

Copyright 2016 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.
Chapter 8 Restricting Rows and Sorting Data 255
Introduction 256
Where Clause Syntax 257
Rules for Character Strings 258
Rules for Dates 260
Comparison Operators 260
BETWEEN ... AND Operator 267
IN Operator 268
LIKE Operator 270
Logical Operators 274
Treatment of Null Values 277
ORDER by Clause Syntax 279
Secondary Sort 282
Sorting by SELECT Order 284
Chapter Summary 285
Chapter 8 Syntax Summary 286
Review Questions 288
Multiple Choice 288
Hands-On Assignments 292
Advanced Challenge 293
Case Study: City Jail 293

Chapter 9 Joining Data from Multiple Tables 295


Introduction 296
Cartesian Joins 297
Cartesian Join: Traditional Method 298
Cartesian Join: JOIN Method 300
Equality Joins 301
Equality Joins: Traditional Method 303
Equality Joins: JOIN Method 308
Non-Equality Joins 314
Non-Equality Joins: Traditional Method 315
Non-Equality Joins: JOIN Method 316
Self-Joins 317
Self-Joins: Traditional Method 318
Self-Joins: JOIN Method 319
Outer Joins 320
Outer Joins: Traditional Method 321
Outer Joins: JOIN Method 324
Set Operators 326
Chapter Summary 334
Chapter 9 Syntax Summary 335
Review Questions 337
Multiple Choice 338
Hands-On Assignments 344

Table of Contents ix

Copyright 2016 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.
Advanced Challenge 345
Case Study: City Jail 345

Chapter 10 Selected Single-Row Functions 347


Introduction 348
Case Conversion Functions 349
The LOWER Function 349
The UPPER Function 350
The INITCAP Function 351
Character Manipulation Functions 352
The SUBSTR Function 352
The INSTR Function 354
The LENGTH Function 356
The LPAD and RPAD Functions 357
The LTRIM and RTRIM Functions 358
The REPLACE Function 359
The TRANSLATE Function 360
The CONCAT Function 360
Number Functions 361
The ROUND Function 361
The TRUNC Function 362
The MOD Function 363
The ABS Function 364
The POWER Function 365
Date Functions 365
The MONTHS_BETWEEN Function 367
The ADD_MONTHS Function 367
The NEXT_DAY and LAST_DAY Functions 368
The TO_DATE Function 369
Rounding Date Values 371
Truncating Date Values 372
CURRENT_DATE Versus SYSDATE 373
Regular Expressions 374
Other Functions 377
The NVL Function 377
The NVL2 Function 380
The NULLIF Function 381
The TO_CHAR Function 383
The DECODE Function 385
The CASE Expression 387
The SOUNDEX Function 387
The TO_NUMBER Function 388
The DUAL Table 389
Chapter Summary 390
Chapter 10 Syntax Summary 390
Review Questions 394

x Table of Contents

Copyright 2016 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.
Multiple Choice 395
Hands-On Assignments 399
Advanced Challenge 399
Case Study: City Jail 400

Chapter 11 Group Functions 401


Introduction 402
Group Functions 403
The SUM Function 404
The AVG Function 406
The COUNT Function 408
The MAX Function 411
The MIN Function 412
Grouping Data 413
Restricting Aggregated Output 417
Nesting Functions 421
Statistical Group Functions 422
The STDDEV Function 422
The VARIANCE Function 423
Enhanced Aggregation for Reporting 424
The GROUPING SETS Expression 427
The CUBE Extension 428
The ROLLUP Extension 431
Pattern Matching 437
Chapter Summary 439
Chapter 11 Syntax Summary 439
Review Questions 441
Multiple Choice 442
Hands-On Assignments 446
Advanced Challenge 447
Case Study: City Jail 447

Chapter 12 Subqueries and MERGE Statements 449


Introduction 450
Subqueries and Their Uses 451
Single-Row Subqueries 451
Single-Row Subquery in a WHERE Clause 451
Single-Row Subquery in a HAVING Clause 456
Single-Row Subquery in a SELECT Clause 457
Multiple-Row Subqueries 459
The IN Operator 460
The ALL and ANY Operators 461
Multiple-Row Subquery in a HAVING Clause 465
Multiple-Column Subqueries 467
Multiple-Column Subquery in a FROM Clause 467
Multiple-Column Subquery in a WHERE Clause 469

Table of Contents xi

Copyright 2016 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.
NULL Values 471
NVL in Subqueries 471
IS NULL in Subqueries 472
Correlated Subqueries 473
Nested Subqueries 475
Subquery Factoring Clause 477
DML Actions Using Subqueries 478
MERGE Statements 479
Chapter Summary 484
Chapter 12 Syntax Summary 484
Review Questions 486
Multiple Choice 486
Hands-On Assignments 492
Advanced Challenge 493
Case Study: City Jail 493

Chapter 13 Views 495


Introduction 496
Creating a View 498
Creating a Simple View 500
DML Operations on a Simple View 504
Creating a Complex View 508
DML Operations on a Complex View with an Arithmetic Expression 508
DML Operations on a Complex View Containing Data from Multiple Tables 513
DML Operations on a Complex View Containing Functions or Grouped Data 515
DML Operations on a Complex View Containing DISTINCT or ROWNUM 517
Summary Guidelines for DML Operations on a Complex View 519
Dropping a View 519
Creating an Inline View 520
CROSS and OUTER APPLY Methods for Joins 520
TOP-N Analysis 522
Creating a Materialized View 527
Chapter Summary 531
Chapter 13 Syntax Summary 532
Review Questions 533
Multiple Choice 533
Hands-On Assignments 537
Advanced Challenge 538
Case Study: City Jail 538

Appendix A Tables for the JustLee Books Database 539


CUSTOMERS Table 539
BOOKS Table 540
ORDERS Table 541
ORDERITEMS Table 542
AUTHOR Table 543
BOOKAUTHOR Table 544

xii Table of Contents

Copyright 2016 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.
PUBLISHER Table 545
PROMOTION Table 546

Appendix B SQL*Plus and SQL Developer Overview 547


Introduction 547
SQL*Plus 547
SQL Developer 551

Appendix C Oracle Resources 555


Oracle Academic Initiative (OAI) 555
Oracle Certification Program (OCP) 555
Oracle Technology Network (OTN) 555
International Oracle Users Group (IOUG) 556

Appendix D SQL*Loader 557


Introduction 557
Read a Fixed File Format 557
Read a Delimited File 559

Appendix E SQL Tuning Topics 561


Introduction 561
Tuning Concepts and Issues 561
Identifying Problem Areas in Coding 561
Processing and the Optimizer 563
The Explain Plan 565
Timing Feature 570
Selected SQL Tuning Guidelines and Examples 571
Avoiding Unnecessary Column Selection 572
Index Suppression 573
Concatenated Indexes 575
Subqueries 576
Optimizer Hints 577

Appendix F SQL in Various Databases 579


Introduction 579
Suppressing Duplicates 579
Locating a Value in a String 580
Displaying the Current Date 580
Specifying a Default Date Format 580
Replacing NULL Values in Text Data 581
Adding Time to Dates 581
Extracting Values from a String 581
Concatenating 582
Data Structures 582

Glossary 583
Index 589

Table of Contents xiii

Copyright 2016 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

The past few decades have seen a proliferation of organizations that rely heavily on
information technology. These organizations store their data in databases, and many
choose Oracle database management systems to access their data. The current Oracle
database version, Oracle 12c, is a database management system that enables users to
create, manipulate, and retrieve data. The purpose of this textbook is to introduce
students to basic SQL commands for interacting with Oracle 12c databases in a business
environment. In addition, concepts relating to objectives of the current Oracle
certification exams have been incorporated for students wanting to pursue certification.

The Intended Audience


This textbook has been designed for students in technical two-year or four-year programs
who need to learn how to interact with databases. Although having an understanding of
database design is preferable, an introductory chapter has been included to review the
basic concepts of E-R modeling and the normalization process.

Oracle Certification Program (OCP)


This textbook covers the objectives of SQL Fundamentals Exams available: 1Z0-051 for
Oracle 11g and Exam 1Z0-061 for Oracle Database 12c. Most objectives for Exam 1Z0-
047, Oracle Database SQL Expert, are also covered. Any of these exams serve as the first
exam in the Oracle Application Development and Oracle Database Administrator Oracle
Certified Associate level certification tracks. Information about registering for these
exams, along with other reference material, is available at www.oracle.com.

The Approach
The concepts introduced in this textbook are discussed in the context of a hypothetical
real-world business: an online book retailer named JustLee Books. The company’s
business operation and the database structure are introduced and analyzed, and as
commands are introduced throughout the textbook, they’re modeled with examples using
the JustLee Books database. Using consistent examples of a hypothetical company helps
you learn the syntax of commands and how to use them in a real-world environment. In
addition, a script file that generates the database is available to give you hands-on practice
in re-creating examples and practicing variations of SQL commands to enhance your
understanding.
To explain what a database is and how it’s created, this textbook initially focuses
on creating tables and learning how to perform data manipulation operations. After
you’re familiar with the database structure, the focus then turns to querying a database.

Copyright 2016 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.
In Chapters 8 through 13, you learn how to retrieve data from the database, using the
many options of a SELECT statement, including row filtering, joins, functions, and
subqueries.
To reinforce the material, each chapter includes a chapter summary and, when
appropriate, a syntax guide for the commands covered in the chapter. In addition, each
chapter includes review questions and hands-on activities that test your knowledge and
challenge you to apply that knowledge to solving business problems. A running case study
that builds throughout the textbook provides a second real-world setting—a city jail
system—as another opportunity to work with databases.

New to This Edition


Topics added covering new Oracle 12c features include:
• Extended data types
• Invisible columns
• Default column values
• Specifying a value for NULL inserts
• Based on a sequence value
• Identity columns
• Left outer join enhancements
• CROSS APPLY join method
• Pattern matching for trend analyses
• Enhanced Top-N-Query features
In addition, coverage of subquery factoring or use of the WITH clause has been added
to Chapter 12.

Overview of This Book


The examples, assignments, and cases in this book help you achieve the following
objectives:
• Issue SQL commands that retrieve data based on criteria specified by
the user.
• Use SQL commands to join tables and retrieve data from joined tables.
• Perform calculations based on data stored in the database.
• Use functions to manipulate and aggregate data.
• Use subqueries to retrieve data based on unknown conditions.
• Create, modify, and drop database tables.
• Manipulate data stored in database tables.
• Enforce business rules by using table constraints.
• Create users and assign the privileges users need to perform tasks.
The chapters’ contents build in complexity while reinforcing previous ideas. Chapter 1
introduces basic database management concepts, including database design. Chapter 2
shows how to retrieve data from a table. Chapter 3 explains how to create new database
tables. Chapter 4 addresses the use of constraints to enforce business rules and ensure the
integrity of table data. Chapter 5 explains adding data to a table, modifying existing data,
and deleting data. Chapter 6 shows how to use a sequence to generate numbers, create

Preface xv

Copyright 2016 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.
indexes to speed up data retrieval, and create synonyms to provide aliases for tables.
Chapter 7 steps you through creating user accounts and roles and shows how to grant (and
revoke) privileges to these accounts and roles. Chapter 8 explains how to restrict rows
retrieved from a table, based on a given condition. Chapter 9 shows how to link tables with
common columns by using joins. Chapter 10 describes the single-row functions supported
by Oracle 12c. Chapter 11 covers the usage of multiple-row functions to derive a single
value for a group of rows and explains how to restrict groups of rows. Chapter 12 covers
using subqueries to retrieve rows based on an unknown condition already stored in the
database. Chapter 13 explains using views to restrict access to data and reduce the
complexity of certain types of queries.
The appendixes support and reinforce chapter materials. Appendix A contains
printed versions of the initial table structure and data for the JustLee Books database used
throughout this textbook. Appendix B introduces the operation of the SQL*Plus and SQL
Developer client software tools. Appendix C lists Oracle resources for further study.
Appendix D introduces the SQL*Loader utility for importing data. Appendix E introduces
basic SQL statement tuning concepts. Appendix F identifies SQL differences in some
popular databases.

Features
To enhance your learning experience, each chapter in this textbook includes the following
elements:
• Chapter objectives: Each chapter begins with a list of the concepts to be
mastered by the chapter’s conclusion. This list gives you a quick overview of
chapter contents and serves as a useful study aid.
• Running case: A sustained example, the business operation of JustLee Books,
is the basis for introducing new commands and practicing the material
covered in each chapter.
• Methodology: As new commands are introduced in each chapter, the
command syntax is shown and then an example, using the JustLee Books
database, illustrates using the command in the context of business
operations. This methodology shows you not only how the command is used,
but also when and why it’s used. The script file used to create the database is
available so that you can work through the examples in this textbook,
engendering a hands-on environment in which you can reinforce your
knowledge of chapter material.
• Tip: This feature, designated by the Tip icon, provides practical advice and
sometimes explains how a concept applies in the workplace.
• Note: These explanations, designated by the Note icon, offer more
information on performing operations with databases.
• Database Preparation: These notes, placed at the end-of-chapter
introductions, tell you which script from the student data files you should
run in preparation for chapter examples and activities.
• Caution: This warning, designated by the Caution icon, points out database
operations that, if misused, could have devastating results.
• Chapter summaries: Each chapter’s text is followed by a summary of chapter
concepts. These summaries are a helpful recap of chapter contents.

xvi Preface

Copyright 2016 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.
• Syntax summaries: Beginning with Chapter 2, a Syntax Guide table is
included after each chapter summary to recap the command syntax covered
in the chapter.
• Review questions: End-of-chapter assessment begins with review questions
that reinforce the main ideas introduced in each chapter. These questions
ensure that you have mastered the concepts and understand the information
covered in the chapter.
• Multiple-choice questions: Each chapter contains multiple-choice
questions covering the material in the chapter. Oracle certification-type
questions are included to prepare you for the type of questions you
can expect on certification exams and measure your level of
understanding.
• Hands-on assignments: Along with conceptual explanations and
examples, each chapter includes hands-on assignments related to the
chapter’s contents. The purpose of these assignments is to give you
practical experience. In most cases, the assignments are based on the
JustLee Books database and build on the examples in the chapter.
• Advanced challenge: This section poses another problem about the JustLee
Books database for you to solve and is larger in scope than the hands-on
assignments.
• Case studies: At the end of each chapter is a major case study, designed
to help you apply what you have learned to real-world situations. These
cases give you the opportunity to synthesize and evaluate information
independently, examine potential solutions, and make recommendations,
much as you would in an actual business situation. These cases uses a
database based on a city jail system.

Supplemental Materials
The following supplemental materials are available when this book is used in a classroom
setting. All teaching tools available with this book are provided to instructors on the
Cengage Learning Web site at www.cengagebrain.com.
• Electronic Instructor’s Manual: The Instructor’s Manual accompanying this
textbook includes the following items:
• Additional instructional material to assist in class preparation, including
suggestions for lecture topics
• A sample syllabus
• When applicable, information about potential problems that can occur in
networked environments
• Cengage Learning Testing Powered by Cognero is a flexible, online system
that allows you to:
• author, edit, and manage test bank content from multiple Cengage
Learning solutions
• create multiple test versions in an instant
• deliver tests from your LMS, your classroom or wherever you want

Preface xvii

Copyright 2016 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.
• PowerPoint presentations: Microsoft® PowerPoint slides are included for
each chapter. Instructors can use the slides in three ways: as teaching
aids during classroom presentations, as printed handouts for classroom
distribution, or as network-accessible resources for chapter review.
Instructors can add their own slides for additional topics introduced to
the class.
• Data files: The script files needed to create the JustLee Books and City
Jail databases are available on the Cengage Learning Web site at www
.cengagebrain.com.
• Solution files: Solutions to chapter examples, end-of-chapter review
questions and multiple-choice questions, hands-on assignments, and case
studies are available on the Cengage Learning Web site at www
.cengagebrain.com. The solutions are password protected.
• Figure files: Figure files allow instructors to create their own presentations
with figures from the textbook.

Acknowledgments
I feel fortunate that Cengage Learning pursued my authorship of this textbook and
continues to support my efforts. I am one lucky person—I have two angels in heaven, my
mother and grandmother, and one angel here on earth, Scott. Without them watching
over me, I would not be able to tackle such challenges. I also want to thank my father,
who always seems more excited than me every time I finish a book project.
However, this textbook is the result of an incredible effort by many people whom
I wish I had the opportunity to thank personally. First, hats off to Lori Bradshaw and
Wendy Langerud of S4Carlisle Publishing Services for managing the content for this
project and keeping everyone on schedule. And a special thank you to Arul Joseph Raj
of Lumina Datamatics LTD for his detailed efforts in preparing, reviewing, and formatting
the content. There were many others involved in this project like product management,
editing, marketing, and art development, and every effort was critical in making this
book a reality. I truly appreciate all of these efforts.
In addition, I need to recognize the enormous contribution of colleagues and
reviewers, who provided helpful suggestions and insight into the development of this
textbook in earlier editions. And, finally, many thanks to the instructors who have
adopted this text and have dedicated their efforts to assist others to learn these most
important database skills.

xviii Preface

Copyright 2016 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.
READ THIS BEFORE YOU BEGIN

TO THE USER

Data Files
To work through the examples and complete the projects in this book, you need to load
the data files created for this book. Your instructor will provide these data files, or you
can download them from the Cengage Learning Web site at www.cengagebrain.com and
then search for this book’s title. The data files are designed to supply the same data shown
in chapter examples, so you can have hands-on practice in re-creating the queries and
their output. The tables in the database can be reset if you encounter problems, such as
accidentally deleting data. Working through all examples is highly recommended to
reinforce your learning.
Starting with Chapter 2, database script instructions are given at the beginning of the
chapter, if applicable. These database script files are in the folder corresponding to the
chapter (Chapter 5, Chapter 10, and so forth) on www.cengagebrain.com and have
filenames such as JLDB_Build_#.sql (substituting the chapter number for the
# symbol). If the computer in your school lab—or your own computer—has Oracle 12c
installed, you can work through the chapter examples and complete the hands-on
assignments and case projects. Many of the coding examples in this textbook can be
completed successfully with previous versions of Oracle (Oracle 10g or Oracle 11g).

Connecting to Oracle
Most colleges will provide various options for accessing Oracle software to execute SQL
statements required in this text, typically via the internet and/or using college computer
labs. Contact your instructor first to identify the options available. If you choose to install
Oracle 12c on your own computer, visit www.oracle.com and go to the database
download area. The database software is freely available for learning purposes, however, it
is very important that you view the documentation for the software prior to downloading
and installing the software. Be sure to review the hardware and software requirements
prior to attempting the install. You will be asked to setup a free Oracle Technology
Network account before downloading. If you are new to Oracle, consult with your
instructor prior to installing Oracle database software for guidance. This text was tested
on Oracle Database 12c release 12.1.0.1.0.
When you install the Oracle software, you’re prompted to change the password for
certain default administrative user accounts. Make sure you record the accounts’ names
and passwords because you might need to log in to the database with one of these
administrative accounts in later chapters. After you install Oracle, you’re required to

Copyright 2016 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.
enter a username and password to access the software. One default username created
during installation is “scott.”
Also, note that you can’t use your own computer to work through chapter examples
and complete projects unless you have the data files. You can get these files from your
instructor, or you can download them from the Cengage Learning Web site at www
.cengagebrain.com and then search for this book’s title. When you download the data
files, they should be stored in a directory separate from any other files on your hard drive.
You need to remember the path or folder containing these files because each script
filename must be prefixed with its location before you run the script.

Visit Our Web Site


A supplemental chapter on formatting report output has been included in the book’s
online materials. Additional materials designed especially for this textbook might be
available on the Cengage Learning Web site. Go to www.cengagebrain.com periodically
and search this site for more details.

TO INSTRUCTORS
To complete examples and activities in this textbook, your students must have access to
the data files included on the Instructor Resources GD (or downloaded from www
.cengagebrain.com).
The data files consist of the JustLee Database folder and a folder for each chapter.
Many chapters require running a script; if so, these instructions are given in a note at the
beginning of the chapter. These scripts are in folders corresponding to the chapter
(Chapter 5, Chapter 10, and so forth) and have filenames such as JLDB_Build_#.sql
(substituting the chapter number for the # symbol). The initial database creation is done
at the beginning of Chapter 2 to create the JustLee Books database. Students should run
the scripts as instructed to have a copy of the tables stored in their schemas. You should
instruct your students on how to access and copy data files to their own computers. The
chapters and projects in this book were tested with Oracle 12c Standard Edition.

Cengage Learning Data Files


You are granted a license to copy data files to any computer or computer network used by
people who have purchased this book.

xx Read This Before You Begin

Copyright 2016 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.
CHAPTER 1
OVERVIEW OF DATABASE
CONCEPTS

LEARNING OBJECTIVES
After completing this chapter, you will be able to do the following:
• Define database terms
• Identify the purpose of a database management system (DBMS)
• Explain database design by using entity-relationship models and
normalization
• Explain the purpose of a Structured Query Language (SQL)
• Understand how this textbook’s topics are sequenced and how the two
sample databases are used
• Identify the software used in this textbook

Copyright 2016 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 INTRODUCTION
Imagine you’re starting up an online book retail company. How will customer orders
be recorded? Will customers be able to search for products by name or keywords? Will you
be able to analyze sales information to track profits, determine product success, and target
marketing efforts to customers? Analyzing thousands of orders could take days without
using a database. A database simplifies these tasks because it’s a storage structure that
provides mechanisms for recording, manipulating, and retrieving data.
The database used throughout this textbook is based on the activities of a
hypothetical business, an online bookseller named JustLee Books. The company sells
books via the Internet to customers throughout the United States. When a new customer
places an order, he or she provides data such as name, billing and shipping addresses, and
items ordered. The company also uses a database for all books in inventory.
To access the data required for operating JustLee Books, management relies on a
DBMS. A database management system (DBMS) is used to create and maintain the
structure of a database, and then to enter, manipulate, and retrieve the data it stores.
Creating an efficient database design is the key to using a database effectively to support
an organization’s business operations.
This chapter introduces basic database terminology and discusses the process of
designing a database for JustLee Books.

DATABASE TERMINOLOGY
Whenever a customer opens an account with a company, certain data must be collected.
In many cases, the customer completes an online form that asks for the customer’s name,
address, and so on, as shown in Figure 1-1.

Customer Information
Name: _________________________________

Street Address: __________________________

City: ________________________ Fields Record

State: _________ Zip: _________


File
Customer A

Customer B

Customer C

FIGURE 1-1 Collecting customer information

While collecting customer information, a series of characters is identified for each item.
A character is the basic unit of data, and it can be a letter, number, or special symbol.

Chapter 1

Copyright 2016 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
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like