Sei sulla pagina 1di 834

Introduction to the Oracle Academy

Copyright 2011, Oracle. All rights reserved.

Introduction to the Oracle Academy

What Will I Learn?


Objectives
In this lesson, you will learn to:
Give examples of jobs, salary and opportunities
available that could result from participating in the
Academy
Understand how participating in the Academy can
help you to realize these opportunities

Copyright 2011, Oracle. All rights reserved.

Introduction to the Oracle Academy

Why Learn It?


Purpose
A passage from a book may get you interested in reading
the whole text. A movie trailer or preview may make you
curious enough to see the film. A food sampled at the
supermarket may result in a product purchase.

The Oracle Academy aims to give you a peek at some of


the skills required in the professional workplace and the
opportunities that could result from learning them.

Copyright 2011, Oracle. All rights reserved.

Introduction to the Oracle Academy

Tell Me / Show Me
Questions to Consider
What kind of career in business or in the technology
industry do you want to have? What types of jobs are
you interested in? What options are you preparing
yourself for?

Copyright 2011, Oracle. All rights reserved.

Introduction to the Oracle Academy

Tell Me / Show Me
Considerations
Labor statistics report a steady increase in
employment opportunities for database and
Internet-trained personnel in many fields,
including:
- Publishing
- Trade
- Business Services
- Membership Organizations
As their Web presence grows in importance
for more and more organizations, there is a
growing demand for skilled professionals to
develop and support Web applications.
Copyright 2011, Oracle. All rights reserved.

Introduction to the Oracle Academy

Tell Me / Show Me
Statistics
Survey
Jobs and salaries in the IT field*
Group

Average
Starting

Average Base
Salary

Business
programmers

54,351

67,382

Communications

44,967

52,945

Computer staff

26,105

29,986

Database
professionals

46,327

53,456

Management

63,470

75,317

Support
professionals

32,926

39,828

* Sample State = California

Copyright 2011, Oracle. All rights reserved.

Introduction to the Oracle Academy

Tell Me / Show Me
Required Education for IT
Positions
Today, so many jobs require an
associates degree or higher
degree. In technology, many
opportunities ask for industryrecognized certifications.
Physical working boundaries
have allowed employers to hire
employees working from remote
locations which has broadened
the pool of candidates. Your
education goals are important in
helping you get into a career that
you enjoy.
Copyright 2011, Oracle. All rights reserved.

Introduction to the Oracle Academy

Tell Me / Show Me
The Oracle Academy
Introducing...
The Oracle Academy

Teacher-led/project-driven
+
I.T. industry-recognized certification
+
Higher-Education options
=
21st-century economic viability

Copyright 2011, Oracle. All rights reserved.

Introduction to the Oracle Academy

Tell Me / Show Me
Oracle Academy Preparation for a Career
Possible Career Path 1
Title: Entry-Level Database Engineer
Maintain data integrity; run database queries
Requirements: 0 - 2 yrs. + bachelor's degree
Salary: $25,000 - $50,000 USD

MOVIE
sdm_s01_l01_a05.swf

Title: Database Administrator (DBA)


Conduct extensive database analysis and
problem solving; maintain database configuration
and ensure data accuracy
Requirements: 2 - 5 yrs. + bachelor's degree
Salary: $65,000 - $90,000 USD
Title: Senior Database Administrator
Develop, implement, enhance, support, and
maintain database
Requirements: 5+ yrs. + bachelor's degree
Salary: $100,000+ USD
Copyright 2011, Oracle. All rights reserved.

Introduction to the Oracle Academy

Tell Me / Show Me
Oracle Academy Preparation for a Career (continued)
Possible Career Path 2
Title: Junior Consultant
Install and troubleshoot client systems
Requirements: 0 - 3 yrs. + bachelor's degree
Salary: $35,000 - $45,000 USD

MOVIE
sdm_s01_l01_a06.swf

Title: Sales Consultant


Assist sales representatives with system
presentations and client needs assessment
Requirements: 2 - 3 yrs. + bachelor's degree
Salary: $50,000 - $90,000 USD
Title: Project Manager
Manage system design, engineering,
implementation, and integration; initiate and
maintain partner relationships
Requirements: 4+ yrs. + bachelor's degree
Salary: $90,000+ USD
Copyright 2011, Oracle. All rights reserved.

10

Introduction to the Oracle Academy

Tell Me / Show Me
The Oracle Academy Database Design and
Programming with SQL Course
This Oracle Academy course is the first of two
courses available to you. This course begins
with topics covering:
Entity relationship modeling, database
design, development, and normalization
History of the database, evolution of
computing
Business skills: presentations, case
studies

Copyright 2011, Oracle. All rights reserved.

MOVIE
sdm_s01_l01_a07.swf

11

Introduction to the Oracle Academy

Tell Me / Show Me
The Oracle Academy Database Design
and Programming with SQL Course
(continued)
This course then continues on to cover
topics including:
SQL (structured query language) The
language of the database
Accessing data with SQL
Data definition, manipulation and
control languages
Transaction control
Building applications
Business skills: interviewing, creating a
career portfolio

Copyright 2011, Oracle. All rights reserved.

12

Introduction to the Oracle Academy

Tell Me / Show Me
The Oracle Academy Database Programming with PL/SQL
Course
This Oracle Academy course is the second of two courses
available to you. Topics covered in this course include:
PL/SQL, a procedural language extension to SQL
Procedural programming structures such as variables,
constants, and parameters
Conditional control statements including IF and CASE
Iterative control statements including LOOP, WHILE, and
FOR
Handling exceptions
Creating procedures, functions, packages, and triggers

Copyright 2011, Oracle. All rights reserved.

13

Introduction to the Oracle Academy

Tell Me / Show Me
Oracle Certifications
The Oracle Academy can prepare you for 2 certifications.
Oracle Database SQL Certified Expert
1Z0-047: Oracle Database SQL Expert

Oracle PL/SQL Developer Certified Associate

SQL

1Z0-051 Oracle Database 11g: SQL Fundamentals I


1Z0-007 Introduction to Oracle9iSQL
1Z0-047 Oracle Database SQL Expert

PL/SQL

(Completion of 1 SQL and 1 PLSQL Exam)

1Z0-147: Programming with PL/SQL


1Z0-144: Oracle Database 11g
Program with PL/SQL
Copyright 2011, Oracle. All rights reserved.

14

Introduction to the Oracle Academy

Summary
Objectives Summarized
In this lesson, you have learned to:
Give examples of jobs, salary and opportunities
available that could result from participating in the
Academy
Understand how participating in the Academy can help
you to realize these opportunities

Copyright 2011, Oracle. All rights reserved.

15

Introduction to the Oracle Academy

Summary
Practice Guide
The link for the lesson practice guide can be found in the course
resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

16

Data vs. Information

Copyright 2011, Oracle. All rights reserved.

Data vs. Information

What Will I Learn?


Objectives
In this lesson, you will learn to:
Distinguish between data and information and provide
examples of each
Describe and give an example of how data becomes
information

Copyright 2011, Oracle. All rights reserved.

Data vs. Information

Why Learn It?


Purpose
All kinds of information (school records, mobile telephone
records, ring tone downloads, grocery purchases) are
stored in databases. We interact with databases every
day, consciously or unconsciously.

It is important to understand what is stored in a database


and what can be retrieved from it.

Copyright 2011, Oracle. All rights reserved.

Data vs. Information

Why Learn It?


Data Compared to
Information
If you work in the information- Data:
technology industry, it is
essential to understand how
data is modeled and stored in
a database.
If you work in any other
industry, you will most likely
have to work with data stored
somewhere on a computer
and probably be required to
use data in your job to create
reports and/or make
decisions.

Lunch Room Data

This report will tell us what our


best-selling lunch items are.

Information:

Copyright 2011, Oracle. All rights reserved.

Data vs. Information

Tell Me / Show Me
Data vs. Information
The words "data" and "information" are often
used as if they are synonyms. Nevertheless,
they have different meanings.

Data: Raw material, from which you can


draw conclusions. Facts from which you can
deduce new facts.

sdm_s03_l04_a03

Information: knowledge, intelligence, a


particular piece of data with a special
meaning or function. Information is often the
result of combining, comparing and
performing calculations on data.

Copyright 2011, Oracle. All rights reserved.

Data vs. Information

Tell Me / Show Me
Data vs. Information (continued)
Whenever a student, teacher, administrator (or any person
using a computer) interacts with a website, pieces of data
are collected. The website application may be unique to that
school or company, but what happens in the background?

Copyright 2011, Oracle. All rights reserved.

Data vs. Information

Tell Me / Show Me
Data vs. Information (continued)
Think about test scores, for example.
In one class, if every student
receives a numbered score, the
scores can be calculated to
determine a class average. The class
averages can be calculated to
determine the school average. The
Oracle database software will
transform recorded/stored data and
statistics into useful pieces of
information.
Data: Each students test score is
one piece of data
Information: The class average
score or the schools average score

Data in

Information out

1997 $1,000,000
1998 $2,000,000

Next years budget

Regulatory
Implementation

Article VI prohibits
use of School
property for

Where are they


going?
DATABASE

312 graduates

98% of students
pass the
Math exam

By how much?
Class average
or school average

Student test
scores were

Copyright 2011, Oracle. All rights reserved.

Data vs. Information

Tell Me / Show Me
What is a Database?
A database is a centralized and structured set of
data stored on a computer system.
It provides facilities for retrieving, adding,
modifying and deleting the data when required.
It also provides facilities for transforming
retrieved data into useful information.
A database is usually managed by a Database
Administrator (DBA).

Copyright 2011, Oracle. All rights reserved.

Data vs. Information

Tell Me / Show Me
Documents, Pictures,
Video and Sound
Within most modern
databases, you can
store and retrieve a wide
variety of data and
documents. Inside the
database, data is stored
in a raw form. When
this raw data is queried
or retrieved, it is
transformed into more
useful output or
information.

Different Data/Sources
Operational

Media-rich

External

Decision support

Documents

Copyright 2011, Oracle. All rights reserved.

Data vs. Information

Tell Me / Show Me
Question: What does a
database have to do with
my everyday life?
Answer: More than you
may realize...
A lot of websites that you
visit are driven by a
database.

Copyright 2011, Oracle. All rights reserved.

10

Data vs. Information

Tell Me / Show Me
Question: If you had one of
the jobs listed below, how
might you use a database?
Database

(1) mechanic in an auto-repair


shop
(2) taxi driver
(3) landscape gardener

Copyright 2011, Oracle. All rights reserved.

11

Data vs. Information

Tell Me / Show Me
Question: Have you ever
returned an item to a store
without a receipt?
What information did you have
to provide?
Were you able to return the
item?

sdm_s03_l04_a02

Copyright 2011, Oracle. All rights reserved.

12

Data vs. Information

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Data
Information
Database

Copyright 2011, Oracle. All rights reserved.

13

Data vs. Information

Summary
Objectives Summarized
In this lesson, you have learned how to:
Distinguish between data and information and provide
examples of each
Describe and give an example of how data becomes
information

Copyright 2011, Oracle. All rights reserved.

14

Data vs. Information

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

15

History of the Database

Copyright 2011, Oracle. All rights reserved.

History of the Database

What Will I Learn?


Objectives
In this lesson, you will learn to:
Describe the evolution of the database and give an
example of its role in the business world
Name important historical contributions in database
development and design
Describe the database development process

Copyright 2011, Oracle. All rights reserved.

History of the Database

Why Learn It?


Purpose
History provides perspective for where we are today in
information technology. The next time you use your
computer, your video gaming system, or your smart phone,
you will realize how far weve come to get to this point and
what events brought us here.
Data Modeling is the first step in database development.
This lesson includes an overview of what the rest of this
course is about.

Copyright 2011, Oracle. All rights reserved.

History of the Database

Tell Me / Show Me
History of the Database Timeline
1960s: Computers become cost effective for private companies along with
increased storage capability.
1970-72: E. F. Codd proposes the relational model for databases, disconnecting
the logical organization from the physical storage.
1976: P. Chen proposes the entity relationship model (ERM) for database design.

Early 1980s: The first commercially-available relational database systems start to


appear at the beginning of the 1980s with Oracle Version 2.
Mid-1980s: SQL (structured query language) becomes "intergalactic standard."

Copyright 2011, Oracle. All rights reserved.

History of the Database

Tell Me / Show Me
History of the Database Timeline (continued)
Early 1990s: An industry shakeout begins with fewer surviving companies.
Oracle survives.
Mid-1990s: Kaboom! The usable Internet/World Wide Web (WWW) appears. A
mad scramble ensues to allow remote access to computer systems with legacy
data.
Late 1990s: The large investment in Internet companies helps create a tools
market boom for Web/Internet/DB connectors.
Early 21st century: Solid growth of DB applications continues. Examples:
commercial websites (yahoo.com, amazon.com), government systems (Bureau
of Citizenship and Immigration Services, Bureau of the Census), art museums,
hospitals, schools, etc.

Copyright 2011, Oracle. All rights reserved.

History of the Database

Tell Me / Show Me
Question: What does a
database have to do
with data modeling?
Data modeling is the first
part of the database
development process.

Database Development Process


Business Information Requirements

Analysis

Conceptual Data
Modeling

Design

Database Design

Build

Database Build

Strategy

Entity Relationship

Table Definitions
Index, View, Cluster

Operational Database
Copyright 2011, Oracle. All rights reserved.

History of the Database

Tell Me / Show Me
Database Development Process Begins With Business
Information Requirements
EXAMPLE
Here is a set of information requirements:
I manage the Human Resources Department for a large company. We need to keep
information about each of our companys employees. We need to track each employee's
first name, last name, job or position, hire date and salary. For any employees on
commission, we also need to track their potential commission. Each employee is
assigned a unique employee number.
Our company is divided into departments. Each employee is assigned to a department -for example, accounting, sales or development. We need to know the department
responsible for each employee and the department location. Each department has a
unique number.
Some of the employees are managers. We need to know each employee's manager and
the employees each manager manages.

Copyright 2011, Oracle. All rights reserved.

History of the Database

Tell Me / Show Me
Database Development
Process
An entity relationship
model should accurately
model the organizations
information needs and
support the functions of
the business.

EXAMPLE
The following entity relationship model represents the
information requirements of the Human Resources
Department.

EMPLOYEE
# number
* first name

assigned to

* last name
* hire date

DEPARTMENT
# number

responsible for

o job
o salary

the manager of

managed by

Copyright 2011, Oracle. All rights reserved.

History of the Database

Tell Me / Show Me
Database Development Process (continued)
In database design, the information requirements reflected in the
entity relationship model are mapped into a relational database
design using a table instance chart. A table instance chart has the
following components:
Table name
Column names
Keys: a primary key (PK) is the unique identifier for each row of
data; a foreign key (FK) links data from one table to another by
referring to a column in that other table
Nulls: indicate if the columns must have a value (mandatory)
Unique: indicates if the value in the column is unique within the
table
Datatype: refers to the format and definition of the data in each
column
Copyright 2011, Oracle. All rights reserved.

History of the Database

Tell Me / Show Me
Database
Development
Process
(continued)
SQL commands
are used to build
the physical
database.
Structured Query
Language (SQL)
is used to create
and manipulate
relational
databases.

DATABASE BUILD
SQL>CREATE TABLE department
2
(deptno
NUMBER(5)
3
name
VARCHAR2(25)
4
loc
VARCHAR2(30)

NOT NULL PRIMARY KEY,


NOT NULL,
NOT NULL);

SQL>CREATE TABLE employees


2
(empno
NUMBER(9)
NOT NULL PRIMARY KEY,
3
fname
VARCHAR2(15) NOT NULL,
4
lname
VARCHAR2(20) NOT NULL,
5
job
VARCHAR2(15),
6
hiredt
DATE
NOT NULL,
7
sal
NUMBER(9,2),
8
comm
NUMBER(9,2),
9
mgr
NUMBER(2)
REFERENCES EMPLOYEES
10 deptno
NUMBER(5)
REFERENCES DEPARTMENT);

Copyright 2011, Oracle. All rights reserved.

10

History of the Database

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Datatype
Foreign key (FK)
Nulls
Primary key (PK)
Table instance chart
Unique

Copyright 2011, Oracle. All rights reserved.

11

History of the Database

Summary
Objectives Summarized
In this lesson, you have learned how to:
Describe the evolution of the database and give an
example of its role in the business world
Name important historical contributions in database
development and design
Describe the database development process

Copyright 2011, Oracle. All rights reserved.

12

History of the Database

Summary
Practice Guide
The link for the lesson practice guide can be
found in the course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

13

Major Transformations in Computing

Copyright 2011, Oracle. All rights reserved.

Major Transformations in Computing

What Will I Learn?


Objectives
In this lesson, you will learn to:
Relate major transformations enabled by changes in
computing to day-to-day activities
Define and give an example of these terms: hardware,
operating system, software
Identify examples of e-businesses that use database
software and explain how it is essential to their success
Explain the overall mission of the Oracle Corporation

Copyright 2011, Oracle. All rights reserved.

Major Transformations in Computing

Why Learn It?


Purpose
History provides perspective for where we are today in
information technology.
If we know where we have come from, it is easier to
understand where we are today, and where we are likely
to go in the future.
The first job you do after you graduate may not exist in 20
years time!

Copyright 2011, Oracle. All rights reserved.

Major Transformations in Computing

Tell Me / Show Me
Key Terms
Hardware: the physical bits and pieces of a
computer, for example keyboard, screen, mouse, disk
drive, memory
Software: programs (sets of instructions) which tell
the hardware what to do.
Operating system: a software program which directly
controls and manages the hardware, for example
Microsoft Windows.
Application: a software program which carries out
specific tasks on behalf of computer users.

Copyright 2011, Oracle. All rights reserved.

Major Transformations in Computing

Tell Me / Show Me
Key Terms (continued)
Client: a workstation or desktop computer including a
screen, keyboard, and mouse. Clients communicate directly
with human computer users.
Server: a more powerful computer that accepts work
requests from clients, does the work, and sends results
back to the client.
Every time you request information from a Web page, your client
computer sends the request to a database on the server. The
server retrieves the data from the database, converts it into useful
information and sends the information back to the client.
If you pursue a career in IT you will hear and use these terms
nearly every day!

Copyright 2011, Oracle. All rights reserved.

Major Transformations in Computing

Tell Me / Show Me
History of Computer
Systems:

1970s Mainframe

MAINFRAME

1970s
The database software
resided in the mainframe
computer. Almost all of the
computer processing was
done on these large
mainframe computers.
Some of these computers
were larger than your
classroom!

Dumb Terminals

DATABASE

Copyright 2011, Oracle. All rights reserved.

Major Transformations in Computing

Tell Me / Show Me
1970s (continued)
Smaller computers, or
dumb terminals, were used
to access the large
mainframe and execute
commands. The terminals
depended on the mainframe
and displayed the results
only after the processing
was completed in the
mainframe. They were not
capable of much processing
on their own.

1970s Mainframe

MAINFRAME

Dumb Terminals

DATABASE

Copyright 2011, Oracle. All rights reserved.

Major Transformations in Computing

Tell Me / Show Me
1980s
As personal computers
(PCs) became faster
and widely available,
processing moved from
the mainframes to the
clients.
Because the PCs had
their own software and
were capable of doing
some processing on
their own, they came to
be known as smart
clients or
workstations.

1980s Personal Computer


Server Computer:
Software

Smart Clients:
GUI Interface and Software

DATABASE

DATABASE

Copyright 2011, Oracle. All rights reserved.

Major Transformations in Computing

Tell Me / Show Me
1980s (continued)
Having the processing
power within the client
machine ushered in a
wave of graphical user
interface (GUI)
applications. Many of
the common
applications today
(Word, Excel,
PowerPoint) were born
during this era.

1980s Personal Computer


Server Computer:
Software

Smart Clients:
GUI Interface and Software

DATABASE

DATABASE

Copyright 2011, Oracle. All rights reserved.

Major Transformations in Computing

Tell Me / Show Me
The Problem of Isolated,
Nonintegrated Systems
Having multiple applications
on multiple client
workstations created new
problems. In this example,
different software on
different systems requires
integration. This is usually
troublesome and
expensive. If an upgrade is
made to a software
application, each and every
server plus each and every
client must be upgraded.

Problems: Different Software

DATABASE

DATABASE

DATABASE

Districts

Statewide
Systems

National
Financial

Copyright 2011, Oracle. All rights reserved.

10

Major Transformations in Computing

Tell Me / Show Me
The Problem of Isolated,
Nonintegrated Systems
(continued)
Think of a school district
updating school grades on one
system and attendance on
another. When a student
graduates, all this information
needs to be brought together.
Without an integrated system,
this can be a painful process.
Especially if there are
thousands of students who
attend thousands of days of
school! Who will pull all that
data together? How?

Problems: Different Software

DATABASE

DATABASE

DATABASE

Districts

Statewide
Systems

National
Financial

Copyright 2011, Oracle. All rights reserved.

11

Major Transformations in Computing

Tell Me / Show Me
1990s and Beyond
Oracles strategy is to
use the Internet and fast
processing servers to
meet the needs of
organizations in storing
data and producing
information.

1990s and Beyond

DATABASE

Database Server:
Software

Application Server:
Software
Thin Clients:
GUI Interface,
Browser

Copyright 2011, Oracle. All rights reserved.

12

Major Transformations in Computing

Tell Me / Show Me
1990s and Beyond

1990s and Beyond

(continued)

The software that


manages the data is on
the database server. It
performs processing for
storage and retrieval.
Applications for business
operations sit on the
application server. It
performs processing for
document creation,
developing, interacting or
manipulating the data.

DATABASE

Database Server:
Software

Application Server:
Software
Thin Clients:
GUI Interface,
Browser

Copyright 2011, Oracle. All rights reserved.

13

Major Transformations in Computing

Tell Me / Show Me
1990s and Beyond

1990s and Beyond

(continued)

Clients can have


applications of their
own, but the essential
business applications
are accessed from
the clients using an
Internet browser.

DATABASE

Database Server:
Software

Application Server:
Software
Thin Clients:
GUI Interface,
Browser

Copyright 2011, Oracle. All rights reserved.

14

Major Transformations in Computing

Tell Me / Show Me
Grid Computing: A New Model
In the grid-computing model, all
of an organizations computers in
different locations can be utilized
just like a pool of computing
resources. Grid computing builds
a software infrastructure that can
run on a large number of
networked servers. A user makes
a request for information or
computation from his/her
workstation and that request is
processed somewhere in the
grid, in the most efficient way
possible.

DATABASE powers the Web


NEWS
SPORTS
ENTERTAINMENT
DATABASE

Copyright 2011, Oracle. All rights reserved.

HOROSCOPES
PICTURES

WEB USERS

MOVIES
CHAT ROOMS
GAMES

15

Major Transformations in Computing

Tell Me / Show Me
Grid Computing: A
New Model (continued)
Grid computing treats
computing as a utility, like
the electric company. You
dont know where the
generator is or how the
electric grid is wired. You
just ask for electricity and
you get it. Grid Computing
improves performance and
reliability for Oracles
system structures using
database servers,
application servers, and
client browsers.

DATABASE powers the Web


NEWS
SPORTS
ENTERTAINMENT
DATABASE

HOROSCOPES

PICTURES

WEB USERS

MOVIES
CHAT ROOMS

Copyright 2011, Oracle. All rights reserved.

GAMES

16

Major Transformations in Computing

Tell Me/ Show Me


Business Terminology
Finance: refers to businesses that deal primarily with
money
Logistics: can be defined as the planning, execution,
and control of the movement and placement of people
and/or goods
Commerce: involves transactions (sales and
purchases) having the objective of supplying goods
and services
Procurement: refers to all of the processes involved in
requesting, ordering, auditing and paying for goods
and services
Distribution: commercial activity of storing and
transporting goods from sellers to buyers
Copyright 2011, Oracle. All rights reserved.

17

Major Transformations in Computing

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Application
Client
Grid computing
Hardware
Infrastructure
Operating system
Server
Software
Finance
Logistics
Commerce
Procurement
Distribution
Copyright 2011, Oracle. All rights reserved.

18

Major Transformations in Computing

Summary
Objectives Summarized
In this lesson, you have learned how to:
Relate major transformations enabled by changes in
computing to day-to-day activities
Define and give an example of these terms: hardware,
operating system, software
Identify examples of e-businesses that use database
software and explain how it is essential to their success
Explain the overall mission of the Oracle Corporation

Copyright 2011, Oracle. All rights reserved.

19

Major Transformations in Computing

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

20

Oracle Academy
Database Design
Instructor Resource Guide
INSTRUCTOR NOTES
SECTION 1 Introduction to the Oracle Academy Lesson
Slide 1: Introduction to the Oracle Academy
Lesson Preparation
This lesson provides both an overview of the Oracle Academy and perspective for the
remainder of the course.
What to Watch For
Help students be realistic about the kinds of jobs they will qualify for when first entering
the job market.
Connections
Encourage students to discuss with their counselor, the counseling center, and their
parents realistic goals for career planning.
Encourage students to continue researching career opportunities and the requirements
needed.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
Tell students about your experience and reasons for teaching the Oracle Academy.
Discuss the benefits you feel the Academy brings to the school and to the students.
Share your enthusiasm!
Share the fact that the Academy is a unique experience that's designed to help students
along the road to success and put them ahead of the game.
Slide 4: Tell Me / Show Me What kind of career do you want?
If students have difficulty getting started, ask them what kind of jobs they would like to
work at. What kind of education do these jobs require? Would a college degree help them
in this job?
Slide 5: Tell Me / Show Me Labor statistics report
Ask students to name jobs in the fields mentioned above.
Answers include:
Publishing: Online magazines need Web developers, editors, reporters, and
editors.
Trade: Foreign-exchange companies need programmers and database
administrators.

Oracle Academy

1
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide

Business services: Financial-services companies need online traders and market


analysts. Call centers need network administrators.
Membership organizations: Users' groups need membership program managers
and Web developers to manage their websites.
Point out that even for non technical jobs such as reporters and editors,
computer skills and familiarity with the Internet are often required.

Ask students: What is a presence on the WWW? Who already has a presence?
Answer: When a company has a website, when business is conducted on the Internet.
Examples: Ford Motor Company, Mitsubishi Corporation, Amazon, Sony Corporation.
Slide 6: Tell Me / Show Me Survey Jobs and salaries in the IT field
Normal salary excluding any special payments such as bonus or overtime
Students should realize the growing demand for IT skills. However, they should also
recognize that most jobs in IT require not only a college education but also some sort of
technical certification. (Explain the chart: starting salary = x and average base salary = y).
Slide 7: Tell Me / Show Me - Required education level
Students should be made aware of the growing demand for IT skills and the education
required to meet those opportunities. In addition to postsecondary education, technical
certifications may also be advantageous. Students will have an opportunity to get started
on their certifications at the end of the Database Programming course with the Intro to
Oracle SQL Certification exam.
Slide 8: Tell Me / Show Me Introducing The Oracle Academy
The Oracle Academy is designed to educate secondary/high school students (ages 16 to
19) on the fundamentals of Internet and database technology and provide them with the
necessary skills to pursue academic and professional opportunities.
The Academy partners with secondary-education institutions to give students not only the
technical skills that they need to survive in today's ever-advancing information age, but
also the business and logic skills that they can carry with them for life.
Slide 9: Tell Me / Show Me For which careers does the Oracle Academy prepare you?
HR is Human Resources (this may not be clear to your students).
Database backups: this is a technique used by DBA's to ensure that if the database
crashes, there will be a copy of the contents available.
Slide 10: Tell Me / Show Me For which careers does the Oracle Academy prepare you?
(continued)
No instructor notes for this slide

Oracle Academy

2
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 11: Tell Me / Show Me For which careers does the Oracle Academy prepare you?
(continued)
In different companies these job titles may be different, but the roles still exist.
These salaries are estimated and based on the U.S. job market. Let students know that
they will be doing their own research on data like this as part of the program.
Slide 12: Tell Me / Show Me Database Design and Programming with SQL
No instructor notes for this slide
Slide 13: Tell Me / Show Me Database Design and Programming with SQL (continued)
No instructor notes for this slide
Slide 14: Tell Me / Show Me Database Programming with PL/SQL
No instructor notes for this slide
Slide 15: Tell Me / Show Me Oracle Certification
No instructor notes for this slide
Slide 16: Tell Me / Show Me Oracle offers educational initiativesThink.com
No instructor notes for this slide
Slide 17: Tell Me / Show Me Oracle offers educational initiatives Thinkquest
No instructor notes for this slide
Slide 18: Tell Me / Show Me Oracle offers educational initiatives OAI
No instructor notes for this slide
Slide 19: Tell Me / Show Me Oracle offers educational initiatives WDP
No instructor notes for this slide
Slide 20: Summary
No instructor notes for this slide
Slide 22: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

3
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 1 - Data vs. Information Lesson
Slide 1: Data vs. Information
No instructor notes for this slide
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It? All kinds of information
No instructor notes for this slide
Slide 4: Why Learn It? If you work in the information-technology industry
No instructor notes for this slide
Slide 5: Tell Me / Show Me Data vs. Information
Data: Raw material, from which you can draw conclusions
Information: Knowledge, intelligence, a particular piece of data with a special meaning
or function
More examples to illustrate the difference between data and information:
Data: telephone directory (names, addresses, and phone numbers). Information: names
and phone numbers of florists in your neighborhood - a useful selection from the data.
Data: gathered during a government population census. Information: totals of people in
the country grouped by age, occupation, which state or district they live in useful
summary calculations from the data.
Slide 6: Tell Me / Show Me Data vs. Information (continued)
Use your background in education to explain how a school or educational institution uses
a database to store information.
The graphical user interface (GUI) is the screen that you see when you look at any
computer application. Students may not be familiar with this term.
Slide 7: Tell Me / Show Me Data vs. Information (continued)
No instructor notes for this slide
Slide 8: Tell Me / Show Me What is a database?
Database: A centralized and structured set of data stored on a computer system
Slide 9: Tell Me / Show Me Documents, Pictures, Video, and Sound
Think of the different kinds of data that a school system stores: student grades, student
pictures, video recordings of school events, etc.

Oracle Academy

4
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 10: Tell Me / Show Me Question: What does a database have to do with
No instructor notes for this slide
Slide 11: Tell Me / Show Me If you had one of the jobs listed below
Ask students to think about how an auto mechanic, taxi driver, or landscape gardener
might use a database?
Possible answers include:
Mechanic: looking up service records on a car; pricing a part carried by a
supplier.
Taxi driver: searching a website such as Yahoo to get driving directions.
Landscape gardener: looking up information on plants or pesticides.
It is useful to understand the data requirements of the business you work in.
Slide 12: Tell Me / Show Me Have you ever returned an item to a store
Lead discussion with students on this topic: Ask students why they think this is
possible?
Currently in some department stores, you can return items without receipts if you wrote a
check or charged it on a credit card. The clerk simply types in your checking-account or
credit-card number and up pops a list of every item you purchased using that payment
type. Thats an example of getting information from a database!
Another example: Have you ever lost your copy of your class grades and had to ask the
school for another copy? What questions did you have to answer, and how did the school
use your answers to provide the copy?
Slide 13: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 14: Summary In this lesson, you have learned how to:
No instructor notes for this slide
Slide 15: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

5
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 1 - History of the Database Lesson
Slide 1: History of the Database
Lesson Preparation
Resources for the history of the database timeline:
http://math.hws.edu
http://wwwdb.web.cern.ch/wwwdb
http://www.falasha-recordings.co.uk
http://news.bbc.co.uk
What to Watch For
No further teaching information for this page.
Connections
Make sure students understand that the use and expansion of Internet technology is at
different stages throughout the world. Encourage students to read and explore advances
in technology in other countries. Help students think globally.
Reinforce Oracle's commitment to education and the reasons why the company feels that
educating young adults is an important goal for society.
Slide 2: What Will I Learn?
Do not spend a long time on the first part of this lesson. The important point is that
students understand that database technology and its uses are not static. Todays
databases are very different from those of 20 years ago. Future databases will be
different again.
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Tell Me / Show Me History of the Database Timeline
Non-relational databases, including hierarchical databases such as IBMs IMS, preceded
relational databases. And some of them are still in use today. This history focuses only
on relational databases, which are easily the most widely used today because of their
flexibility and relative ease of use.
Slide 5: Tell Me / Show Me History of the Database Timeline (continued)
No instructor notes for this slide
Slide 6: Tell Me / Show Me Question: What does a database
No instructor notes for this slide

Oracle Academy

6
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 7: Tell Me / Show Me Database Development Process Begins With
No instructor notes for this slide
Slide 8: Tell Me / Show Me Database Development Process
Share with students that this is exactly what they will learn in the Data Modeling course.
They will be able to transform business requirements into data models (ERDs).
Slide 9: Tell Me / Show Me Database Development Process (continued)
Datatype: to the format and definition of the data in each column
Primary key (PK) is the unique identifier for each row of data
Foreign key (FK) links data from one table to another by referring to a column in that
other table
Nulls: indicate if the columns must have a value (mandatory)
Unique: indicates if the value in the column is unique within the table
Table instance chart: A relational database design used to map the information in the
entity relationship model
Students will also learn how to do this later in this course.
Slide 10: Tell Me / Show Me Database Development Process (continued)
Ask students what they think this means? Answer: In SQL, theyll learn how to make
the actual database. Right now, its all about understanding what is needed using smart
planning and careful design.
Slide 11: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 12: Summary In this lesson, you have learned how to:
No instructor notes for this slide
Slide 13: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

7
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 1 - Major Transformations in Computing Lesson
Slide 1: Major Transformations in Computing
Lesson Preparation
No further instructions for lesson preparation.
What to Watch For
Continue to encourage students to think globally. Encourage them to find other Internet
sites of business around the world.
Connections
Ask students what they predict shopping habits will be like in the next 20 years.
Will we shop online for all our goods and services? How will today's local small
businesses compete? Are there businesses that won't ever need a database or visibility on
the Internet?
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Tell Me / Show Me Key terms
Ask students for specific examples of hardware, operating systems, and software.
Answers will vary, but possible responses include:
Hardware - workstation (desktop) computer, mainframe, monitor, keyboard
Operating systems - Windows XP, Linux, Mac OS X
Applications - games, MSOffice, Macromedia Flash, Adobe Photoshop, etc.
Slide 5: Tell Me / Show Me Key terms (continued)
Two more terms you may want to mention: in a 2-tier system, clients communicate
directly with servers. In a 3-tier system, clients communicate with a third computer in
the middle, which forwards the requests to the servers. The middle-tier computer is often
called an application server or web server.
Slide 6: Tell Me / Show Me History of Computer Systems: 1970s
Point out a disadvantage of this system: if the mainframe computer fails, no work can be
done.
Slide 7: Tell Me / Show Me 1970s (continued)
No instructor notes for this slide

Oracle Academy

8
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 8: Tell Me / Show Me 1980s
No instructor notes for this slide
Slide 9: Tell Me / Show Me 1980s (continued)
Contrast a GUI application (like anything on the Internet) with a non-GUI application
that is just all text. Your students may not even be old enough to remember anything like
it. However, they will understand that displaying graphics requires more memory and
processor speed (they know this from their video games). The earliest PCs were not
equipped with enough muscle for GUI interfaces.
Slide 10: Tell Me / Show Me - The Problem of Isolated, Nonintegrated Systems
This is a problem that a lot of companies face if they have disparate systems that evolved
separately.
Slide 11: Tell Me / Show Me The Problem of Isolated, Nonintegrated Systems
(continued)
No instructor notes for this slide
Slide 12: Tell Me / Show Me 1990s
No instructor notes for this slide
Slide 13: Tell Me / Show Me 1990s (continued)
An example would be a program that manages human-resource data or school records.
Ideally, client users only need a browser to use the application, which then accesses the
database. Advances in processing power allow this type of transaction to take place
quickly and efficiently.
This allows changes or upgrades to be made on the servers once instead of having to
change and maintain many software applications on many client machines.
The slide shows only one database server and one application server, but there could be
several of these.
Slide 14: Tell Me / Show Me 1990s (continued)
No instructor notes for this slide
Slide 15: Tell Me / Show Me Grid Computing: The New Model
No instructor notes for this slide
Slide 16: Tell Me / Show Me Grid Computing: The New Model (continued)
No instructor notes for this slide

Oracle Academy

9
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 17: Tell Me / Show Me View the video clip
See if students recognize any of the sites. Discuss what kind of transactions can be
conducted on the Internet (for example: buy books/cds on amazon.com). Point out that
behind the scenes, computers are working to display the information on the web. Use the
example of amazon.com: if you have previously purchased something from them, they
know you the next time you visit the site. They make recommendations based on
products you bought before. Where is all this information stored? (Answer: in a
database)
Most students may not be familiar with how businesses work. The terms finance,
logistics, commerce, procurement, and distribution may be difficult to understand in
context. Relate these terms to businesses that most will understand such as an online
bookstore, the local grocery store or a clothing store.
Finance: refers to businesses that deal primarily with money. Examples: banks,
brokerage firms, real-estate money lenders
Logistics: can be defined as the planning, execution, and control of the movement and
placement of people and/or goods, and of the supporting activities related to such
movement and placement within a system organized to achieve specific objectives.
Examples: airlines, freight companies, food establishments
Commerce: involves transactions (sales and purchases) having the objective of
supplying commodities (goods and services). Examples: retail stores, online catalog sites
Procurement: refers to all of the processes involved in requesting, ordering, auditing,
and paying for goods and services. Procurement software tracks all the possible codes,
inventories, addresses, etc. for producing, shipping, or ordering a specific product.
Examples: office-supplies ordering system, ordering of uniforms for the military
Distribution: the commercial activity of transporting and selling goods from a producer
to a consumer. Examples: shippers (UPS, Fedex, DHL)
Note: There are overlaps between these terms. Example: Logistics may involve using
procurement and distribution software. Commerce may involve financial applications.
Slide 18: Tell Me / Show Me Business terminology
Finance: refers to businesses that deal primarily with money
Logistics: can be defined as the planning, execution, and control of the movement and
placement of people and/or goods, and of the supporting activities related to such
movement and placement within a system organized to achieve specific objectives.
Commerce: involves transactions (sales and purchases) having the objective of
supplying commodities (goods and services).
Procurement: refers to all of the processes involved in requesting, ordering, auditing,
and paying for goods and services.
Distribution: the commercial activity of transporting and selling goods from a producer
to a consumer.

Oracle Academy

10
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 19: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 20: Summary In this lesson you have learned how to:
No instructor notes for this slide
Slide 21: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

11
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
PRACTICE SOLUTIONS
SECTION 1 Introduction to the Oracle Academy Lesson
Try It / Solve It
1. This activity aims to develop your skills for locating, evaluating, and interpreting IT
career information. Use Internet resources provided by your teacher to identify a job
in the IT career field that interests you. Then, answer the following questions about
that career:
a.
b.
c.
d.
e.
f.
g.
h.

What are the typical tasks involved in this job?


What kind of social, problem-solving or technical skills are required?
What are the physical demands of the job?
What kind of training/education is required for the job?
Where are current job openings?
What other jobs could be a starting job that leads to this career?
How many different kinds of businesses use these job skills?
What is the salary range?

Solution:
Using Internet resources, ask students to identify a job in the IT career field that
interests them and answer the questions about that career. You can use the resources
provided below, or find more with your preferred Internet search engine using the
keywords: "jobs + asia sites", "jobs + europe sites"
Jobs in the United States
US Department of Labor Career Guide to Industries: Excellent resource for all
types of job working conditions, occupations, predicted growth/decline
Portal to a list of IT companies.: Many of the sites have a "career" link that
provides information about the type of jobs each offers
Alphabetical list of jobs such as "database developer" with specific company
job descriptions
Job seekers and employers
http://www.google.com - keyword "Information Technology careers"
Jobs in Eastern Europe, Belarus, Romania, Russia, Czech Republic and
Hungary
Lists of job search sites
http://www.ngonet.org/jobs
http://www.job-hunt.org/europ.shtml
http://www.monster.co.uk/

Oracle Academy

12
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Jobs in Asia Pacific
http://www.escapeartist.com/as/pac.htm
2. Describe how one of the Academy courses and a certification exam could help you
with your future job opportunities.
Solution: Answers will vary.

Oracle Academy

13
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 1 - Data vs. Information Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Database

A collection of data arranged for ease and speed of


search and retrieval.

Graphic User Interface (GUI)

An interface for issuing commands to a computer


utilizing a pointing device, such as a mouse, that
manipulates and activates graphical images on a
monitor.

Data

Raw material, from which you can draw conclusions

Information

Knowledge, intelligence, a particular piece of data


with a special meaning or function

Try It / Solve It
1. List specific data that the school collects about each student. What information could
be gathered using all the student data?
Possible responses for data include: name, address, phone number, names of
parents or guardian, age, sex, nationality, parking place, discipline history, academic
history or attendance history, grades, test scores, ethnic background.
Possible responses for information include: The ethnic groups represented in the
school, what percentage of students drive a car to school, how many students have
grade-point averages greater than 3.0 (information), performance of different ethnic
groups on standardized tests, diversity of the school population, possible locations for
new schools, etc.

Oracle Academy

14
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
2. Review an online database such as:
http://www.archives.gov
http://www.ellisislandimmigrants.org
http://newdeal.feri.org/index.htm
http://www.pro.gov.uk/
http://nationalarchives.nic.in/
a. Write examples of data and information related to the site you choose.
b. State why you believe data collections of this type could be important.
Possible answers: to keep a historical record of immigration into a country, laws
passed, etc.
3. Choose a website, find 10 data items on the site and list 5 pieces of information that
could be gleamed from the data.
Solution: Have students share their data in a game with the students competing to see
who has the most unique data and information. One student reads his/her list of data
aloud. If someone else in class has that piece of data or information, no one gets a
point for it. If only that student has the data/info on his/her list, that student gets a
point. Go through all data/info items and have students report their points. Reward the
highest score!
4. Give examples of how data becomes information for these two industries: film/movie,
hospital/healthcare.
Some answers may include:
Film data: cast, directors, producers, awards, box office figures
Information: type of movies that win the most awards, actors who consistently appear
in the top-grossing movies, studios that produce the most profitable movies
Hospital data: patient names, diagnosis, medication, tests, etc.

Oracle Academy

15
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
5. Name all the different kinds of information that appear on the Lunch Room Data
Report.
Date
12/02/03
12/03/03
12/04/03
12/05/03
12/06/03

Student
Sales
497
440
447
442
330

Faculty/Staff
Sales
23
19
30
27
12

Hamburger/Taco
Bar
335
285
301
325
229

Pizza Bar
122
126
126
107
83

Soup/Salad
Bar
63
48
50
37
30

a. What does this report mean?


It is about food items purchased in a lunch room, most likely in a school.
b. What data was collected?
The table shows the count of types of food items (hamburger/taco, pizza,
soup/salad) purchased per day, broken out by faculty sales and student sales.
It seems that the data is collected weekly.
c. What information does this table provide?
The table gives us information about which items are the most popular.
d. How do you think these data are used?
It could be used to plan inventory for food and to assign duties in the kitchen
and at the serving counter.
e. Generate at least two conclusions based on the data provided.
Hamburgers and tacos are the most popular food; soup and salad are the
least popular.
f. Generate at least two questions that you would ask about the data provided.
Do students and teachers prefer the same food? How do the total counts for
students and teachers break down in terms of type of food purchased?

Oracle Academy

16
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 1 - History of the Database Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Table instance chart

A relational database design used to map the


information in the entity relationship model

Primary key (PK)

the unique identifier for each row of data

Foreign key (FK)

Links data from one table to another by referring to a


column in the other table

Nulls

Columns that must have a value assigned to them

Unique

Indicates if the value in the column is unique within


the table

Datatype

Refers to the format and definition of the data in


each column

Try It / Solve It
1. Complete the diagram by listing in the boxes, the important aspects of the database
evolution. Refer to answer for question 5

2. True or False: The Personal Digital Assistant (PDA) was an important historical
contribution in database development and design
True
3. Name two important historical contributions in database development and design.
Answers will vary

Oracle Academy

17
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
4. If Building the database is the third major task in the database development process
then what are the first two major tasks? Data Modeling, Database Design
5. (Optional) List at least three timeline events in the evolution of the database.
1960s: Computers become cost effective for private companies along with increased
storage capability.
1970-72: E.F. Codd proposes the relational model for databases, disconnecting the
logical organization from the physical storage.
1976: P. Chen proposes the entity relationship model (ERM) for database design.
Early 1980s: The first commercially-available relational database systems start to
appear at the beginning of the 1980s with Oracle Version 2.
Mid-1980s: SQL (structured query language) becomes "intergalactic standard."
Early 1990s: An industry shakeout begins with fewer surviving companies. Oracle
survives.
Mid-1990s: Kaboom! The usable Internet/World Wide Web (WWW) appears. A mad
scramble ensues to allow remote access to computer systems with legacy data.
Late 1990s: The large investment in Internet companies helps create a tools market
boom for Web/Internet/DB connectors.
Early 21st century: Solid growth of DB applications continues. Examples:
commercial websites (yahoo.com, amazon.com), government systems (Bureau of
Citizenship and Immigration Services, Bureau of the Census), art museums, hospitals,
schools, etc.
6. (Optional) To most of us, the Internet has become an essential element in the way we
communicate, the way we do business, and the way we learn. Surprisingly, few
people really know the history and the people that have contributed to its phenomenal
growth.
In this activity, you and your classmates will construct a wall mural timeline of the
major historical events in Internet history. Using Internet resources, your group will
be assigned one topic from the research list. Your group's task is to gather
information to add to the classroom timeline:
Find four events that describe your topic. Each event must have a person, place,
and/or thing associated with it. Add your group's information to the timeline.
Research List:
Historical thinkers: people without whose inventions computers and
communication as we know it today could not be possible
Enablers: universities, government agencies, and businesses that contributed
to the idea of the Internet and birth of the Internet
Communicators: people who developed computer languages, computer
networks, and the technology to be able to talk computer to computer
Oracle Academy

18
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide

Innovators: people and businesses that enabled the average person to be able
to use a computer and communicate on the Internet
Movers and shakers: people and companies that transformed the Internet into
a virtual mall of information and services

Solution:
In this lesson, students will use the Internet to research the people and businesses that
contributed to the development of the Internet. Internet search keywords "internet
timeline" or "Hobbe's Internet Timeline."
Using adding-machine-tape paper or poster paper cut into strips, create a 10-foot
mural for the classroom. Divide the paper into a timeline as follows: allow about 1/4
of the length from 1800 to 1970 and the remaining 3/4 from 1970 to present.
Assign topics to groups. Each group should find a minimum of four events.
Each group must identify a person, a place, and a thing associated with their topic.
The topics to be included are:

Historical thinkers: people without whose inventions computers and


communication as we know it today could not be possible (Samuel Morse,
Alexander Graham Bell, Vannevar Bush)
Enablers: universities, government agencies, and businesses that contributed
to the idea of the Internet and birth of the Internet (ARPANET, NSF, CERN,
Rand Corp.)
Communicators: people who developed computer languages, computer
networks, and the technology to be able to talk computer to computer (Ray
Tomlinson, Bob Metcalf, Vinton Cerf, Larry Wall)
Innovators: people and business that enabled the average person to be able
to use a computer and communicate on the Internet (Microsoft, Apple, AOL,
Netscape, Yahoo)
Movers and shakers: people and companies that transformed the Internet
into a virtual mall of information and services (Oracle, Amazon.com, EBay,
MSN)

Oracle Academy

19
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 1 - Major Transformations in Computing Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Infrastructure
Grid computing

Software

The basic framework or features of a system


A global effort to develop an environment in which
individual users can access computers, databases,
and experimental facilities simply and transparently,
without having to consider where those facilities are
located
The programs, routines, and symbolic languages that
control the functioning of the hardware and direct its
operation.

Hardware

A computer and the associated physical equipment


directly involved in the performance of dataprocessing or communications functions.

Operating System

Software designed to control the hardware of a


specific data-processing system in order to allow
users and application programs to make use of it.

Application

A software program which carries out specific tasks


on behalf of computer users
A workstation or desktop computer including a
screen, keyboard, and mouse; communicates directly
with the user
A more powerful computer which accepts work
requests from clients, does the work, and sends
results back to the client

Client

Server

Try It / Solve It
1. Provide a definition and an example of each of these:
a. Hardware: the physical components of a computer. Mouse, keyboard, screen,
memory, stick drive are some examples
b. Operating system: a software program which directly controls and manages the
hardware. Sun Solaris, Microsoft Windows, Red Hat Linux are examples
c. Software: programs (sets of instructions) which tell the hardware what to do.
Microsoft Word, Palm Desktop, Mozilla Browser are examples

Oracle Academy

20
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
2. How has the major transformation of cell phones impacted day-to-day activities of a
service repair company what can the service repair person do today that they could
not do before this transformation?
Answers will vary. Students should be able to point out that cell phones now enable
a service repair person to call before arriving, call to inform the customer if they are
going to be late, call to order parts before returning to the depot, etc.
3. List three e-businesses that use database software and describe how the database
software is being used.
Answers will vary. Check for students understanding that database software, for any
business, can store and display information stored in the database.
4. Write down the steps of a simple credit-card transaction. How many places does the
information go, and what happens if the transaction is not complete at any one of the
steps? What role does a database play in this process?
Note: The students may not have all these steps. That is all right as long as they have
a general idea of how a database plays a big role in the process.
Solution: Steps in a simple credit-card transaction:
a. Customer presents credit card.
b. Store runs credit card through the system to get customer information: card
number, name.
c. Store takes the customer information and creates an entry for the purchase, using
information from its database (item number, price, discount, etc.).
d. Store information, details and amount of purchase is sent to the credit card
company for approval.
e. Credit card company uses customer information from its own database to check
credit limit, run identity-theft checks, etc.
f. Both databases (store and credit-card company) are updated.
g. If at any time the transaction is not completed (customer changes mind and stops
transaction, or transaction puts customer over the credit limit), the purchase
information is not entered in either database.
h. If identity theft is suspected, credit-card company will create a record in its
database and contact credit-card owner. Sale may not be completed if the creditcard company blocks the purchase.

Oracle Academy

21
Database Design
Copyright 2011, Oracle. All rights reserved.

Drawing Conventions for Readability

Copyright 2011, Oracle. All rights reserved.

Drawing Conventions for Readability

What Will I Learn?


Objectives
In this lesson, you will learn to:
Apply the Oracle drawing conventions to a datamodel
diagram
Identify high volume entities in a datamodel diagram and
explain their significance to the business
Redraw a given datamodel diagram to increase clarity
and readability
Recognize the usefulness of dividing a complex ERD into
a number of functional sub-diagrams

Copyright 2010, Oracle. All rights reserved.

Drawing Conventions for Readability

Why Learn It?


Purpose
What if all shoemakers made up their
own sizes?

sdm_s11_l02_a01

What if every architect used a different


system to draw plans for a building?
Following the same conventions makes it
easier to work as part of a team.
Watch the video clip. How easy is it to
understand the ERD at the end?

Copyright 2010, Oracle. All rights reserved.

Drawing Conventions for Readability

Tell Me / Show Me
Large ERD Drawing
Conventions
As the ERD gets bigger and more
complicated, it becomes more
challenging to lay it out in a clear
and readable format.

sdm_s11_l02_a02

Copyright 2010, Oracle. All rights reserved.

Drawing Conventions for Readability

Tell Me / Show Me
Large ERD
Drawing
Conventions
(continued)
Following the
conventions of
crows flying
south and east
places the high
volume entities
on the upper left
portion of the
ERD.

JOB ASSIGNMENT

CLIENT

EVENT

PRIVATE SPACE

PARTNER

PUBLIC SPACE

Copyright 2010, Oracle. All rights reserved.

Drawing Conventions for Readability

Tell Me / Show Me
Large ERD
Drawing
Conventions
(continued)
High volume
entities are
those that would
have the most
number of
instances,
compared to
other entities.

JOB ASSIGNMENT

CLIENT

EVENT

PRIVATE SPACE

PARTNER

PUBLIC SPACE

Copyright 2010, Oracle. All rights reserved.

Drawing Conventions for Readability

Tell Me / Show Me
Large ERD Drawing Conventions
(continued)
Following the conventions of crows
flying north and west places the
high volume entities on the lower
right portion of the ERD.

PRIVATE SPACE

PUBLIC SPACE

CLIENT

EVENT

PARTNER

JOB ASSIGNMENT

Copyright 2010, Oracle. All rights reserved.

Drawing Conventions for Readability

Tell Me / Show Me
Large ERD Drawing
Conventions
(continued)
High volume entities
are often the central
or more important
entities in an ERD.
They will have the
highest number of
relationships to other
entities, and most of
the business functions
will affect the data
stored in this entity.

PRIVATE SPACE

PUBLIC SPACE

CLIENT

EVENT

PARTNER

JOB ASSIGNMENT

Copyright 2010, Oracle. All rights reserved.

Drawing Conventions for Readability

Tell Me / Show Me
Clarity Is Key
Often you will
have a mix,
depending on
the amount of
space you have
and your own
preference.

CLIENT

JOB
ASSIGNMENT

EVENT

PARTNER

Clarity and
readability are
the main criteria.
PRIVATE SPACE

PUBLIC SPACE

Copyright 2010, Oracle. All rights reserved.

Drawing Conventions for Readability

Tell Me / Show Me
Clarity is Key (continued)
The high volume entities are
not always the most
important.

ENROLLMENT

CLASS

Which of these entities


would have the highest
volume?
STUDENT

TEACHER

Which entity is the most


important?
Again, clarity and readability
are the main criteria.
Copyright 2010, Oracle. All rights reserved.

10

Drawing Conventions for Readability

Tell Me / Show Me
Space is Needed
Readability takes space and is subject to taste. The use of
white space helps clarify an ERD.
B

A
B

A
E

Copyright 2010, Oracle. All rights reserved.

11

Drawing Conventions for Readability

Tell Me / Show Me
Use Sub -Diagrams
When you have a very
large diagram, it may
also help to break it up
into smaller diagrams of
functionally related
entities. You could use
the smaller subdiagrams when
presenting to different
groups within the
customers company.
This is what the project
manager would mainly
be interested in.

JOB ASSIGNMENT
* status
# date

PARTNER
# id
* first name
* last name
DJ
* specialty

EVENT
PLANNER

OTHER

MANAGER
o authorized expense limit

Copyright 2010, Oracle. All rights reserved.

EVENT
# id
* cost
* name
* date
description

CLIENT
# number
* first name
* last name
* phone number
email address

12

Drawing Conventions for Readability

Tell Me / Show Me
Sub-Diagram
Example
These entities are
what the event
manager would
be most
concerned with.

CLIENT
# number
* first name
* last name
* phone number
o email address

EVENT
# id
* cost
* name
* date
o description

THEME
# code
* description

PRIVATE HOME
# id
* address
o comments

PUBLIC SPACE
# id
* address
* rental fee
o comments

Copyright 2010, Oracle. All rights reserved.

13

Drawing Conventions for Readability

Tell Me / Show Me
Sub-Diagram Strategy
Often multiple
developers build the
applications that access
a single database. Each
application developer
could use a smaller
diagram that contains
the entities that he or
she will build screens,
forms, and reports for.
These are the entities
that one of greatest
interest to the DJ, or
someone building an
application for the DJ.

PLAY LIST ITEM


o comments

EVENT
# id
* name
* date
* cost
o description

THEME
# code
* description

TRACK LISTING
* track

CD
# number
* title
* producer
* year

SONG
# id
* title
o duration
o artist

TYPE
# code
* description

Copyright 2010, Oracle. All rights reserved.

14

Drawing Conventions for Readability

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
High volume entity
White space

Copyright 2010, Oracle. All rights reserved.

15

Drawing Conventions for Readability

Summary
Objectives Summarized
In this lesson you have learned to:
Apply the Oracle drawing conventions to a datamodel
diagram
Identify high volume entities in a datamodel diagram and
explain their significance to the business
Redraw a given datamodel diagram to increase clarity
and readability
Recognize the usefulness of dividing a complex ERD
into a number of functional sub-diagrams

Copyright 2010, Oracle. All rights reserved.

16

Drawing Conventions for Readability

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

17

Generic Modeling

Generic Modeling

Copyright 2011, Oracle. All rights reserved.

Generic Modeling

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define generic modeling
Evaluate and describe the advantages
and disadvantages of generic modeling
Construct a generic version of a more
specific data model

Copyright 2011, Oracle. All rights reserved.

Generic Modeling

Why Learn It?


Purpose
Generic models can reduce the number of
entities in a diagram and provide a lot of
flexibility in unstable situations, where the
business requirements change often.

sdm_s11_l03_a01

A business that needs to frequently add


entities and/or attributes could benefit from
generic modeling. One example would be
a pawnshop that buys and sells different
types of items all the time. It would be
difficult to predict the number of item types
and the different attributes each type
would have.

Copyright 2011, Oracle. All rights reserved.

Generic Modeling

Tell Me / Show Me
Generic
Modeling
Generic
modeling looks
at the same
context from
another, more
distant
perspective.
From a distance,
many things look
the same.

MANUFACTURER
# name

MANUFACTURER
# name
the
producer

the
producer

ARTICLE TYPE
# name

GENERIC MODEL

SHIRT
* id
* length
produced
* material
SKIRT
* neck
size
# id
DRESS
* sleeve
length
* length
# id
* material
* lengthtype
* waistband
PANTS
*
material
* hem circum
# id
* bodice style
* length
* material
waistband type

Copyright 2011, Oracle. All rights reserved.

produced

classified

ARTICLE
# id
* length
* material
waistband type
bodice cut
hem circumference
neck size
sleeve length
4

Generic Modeling

Tell Me / Show Me
Choosing a Generic Model
Suppose you are to make a model for a
clothing store. The business typically sells
many different articles: shoes, shirts, dresses,
pants, and so on. For each type of clothing
article, there are different attributes. You can
model every type as an entity. Or you could
create a more generic model that uses one
entity, ARTICLE, with or without subtypes.

However, this model would be fine only if


there were no (or possibly very few) new
instances of ARTICLE TYPE during the life
cycle of the system.
Copyright 2011, Oracle. All rights reserved.

Generic Modeling

Tell Me / Show Me
Recycling of Attributes
Another generic model
involves recycling
attributes.
Using this structure, here
are some examples of
instances of ARTICLE
TYPE:

ARTICLE TYPE
# name
* definition of Prop. 1
* definition of Prop. 2
* definition of Prop. 3
o definition of Prop. 4

MANUFACTURER
# name

the classification
for

classified
by

the producer
of

Copyright 2011, Oracle. All rights reserved.

VALUE
* value of Prop. 1
* value of Prop. 2
* value of Prop. 3
o value of Prop. 4
o value of Prop. 5
o value of Prop. 6
o value of Prop. 7

produced
by

Generic Modeling

Tell Me / Show Me
Recycling of Attributes (continued)
Name

Def. of
Prop. 1

Def. of Prop
2

Def. of
Prop 3

Def of
Prop 4

Def of
Prop 5

SHIRT

id

Length

Material

Neck Size

Sleeve
Length

SKIRT

Id

Length

Material

Waistband
Type

Hem
Circum.

DRESS

id

Length

Material

Bodice
Style

PANT

id

Length

Material

Waistband
Type

You can also store information about the data types of each
property in the definition attributes (example: property 2 for all
articles (length) has a data type of number, property 4 of
DRESS (bodice style) is stored as text).

Copyright 2011, Oracle. All rights reserved.

Generic Modeling

Tell Me / Show Me
Example
These would be the examples of corresponding instances of
ARTICLE.
ARTICLE TYPE
# name
* definition of Prop. 1
* definition of Prop. 2
* definition of Prop. 3
o definition of Prop. 4

MANUFACTURER
# name

the classification
for

classified
by

the producer
of

VALUE
* value of Prop. 1
* value of Prop. 2
* value of Prop. 3
o value of Prop. 4
o value of Prop. 5
o value of Prop. 6
o value of Prop. 7

produced
by

Copyright 2011, Oracle. All rights reserved.

Generic Modeling

Tell Me / Show Me
Generic Values
Using this method, you can add new types of articles fairly
easily, provided that the number of attributes does not exceed
the maximum that was originally defined.
ARTICLE
TYPE
Name

Def. of
Prop. 1

Def. of
Prop 2

Def. of
Prop 3

Def of
Prop 4

Def of
Prop 5

SHIRT

DNM105

40

Denim

16

33

SKIRT

LIN200

22

Linen

Elastic

60

DRESS

SHF119

60

Jersey

Empire

PANT

CHN407

33

Khaki

Flat Front

Copyright 2011, Oracle. All rights reserved.

Generic Modeling

Tell Me / Show Me
Attributes Modeled as
Property Instance

This model takes a third


approach. Every value for a
property of an ARTICLE is
stored separately. This model
gives a lot of freedom to define
new articles and properties
during the life cycle of the
system.
Using this structure, here are
some examples of instances of
each entity:

MANUFACTURER
* name
the
producer
of

ARTICLE TYPE
# name

the
classification
for

produced
by

ARTICLE
# id

the
owner
of

classified
by

owned
by

PROPERTY
# number

the
holder
of

contained
in

held
by

the
container
for

ARTICLE PROPERTY VALUE


* value

Copyright 2011, Oracle. All rights reserved.

10

Generic Modeling

Tell Me / Show Me
Attributes Modeled as Property Instance (continued)
ARTICLE

PROPERTY

ARTICLE TYPE

Article Type
Name

Id

Article
Type Name

No.

Desc.

SHIRT

Length

SHIRT

DNM105

SHIRT

Material

SKIRT

LIN200

SHIRT

Neck size

DRESS

SHF119

SKIRT

Length

PANTS

CHN407

Name

SKIRT

SHIRT
DRESS
PANT

ARTICLE PROPERTY VALUE


Article ID

Article Type Name

PROPERTY Number

Value

DNM105

SHIRT

40

DNM105

SHIRT

Denim

DNM105

SHIRT

16

LIN200

SKIRT

22

Copyright 2011, Oracle. All rights reserved.

11

Generic Modeling

Tell Me / Show Me
Generic Model Benefits
The benefits of a generic model include:
(1) Flexible -- can prevent the need to
change data structures in the future
(2) Can reduce the number of entities
dramatically

Cost: Increased complexity in both the data


model and application programs

Copyright 2011, Oracle. All rights reserved.

sdm_s11_l03_a02

12

Generic Modeling

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Generic
Perspective

Copyright 2011, Oracle. All rights reserved.

13

Generic Modeling

Summary
Objectives Summarized
In this lesson, you have learned to:
Define generic modeling
Evaluate and describe the advantages and
disadvantages of generic modeling
Construct a generic version of a more specific data
model

Copyright 2011, Oracle. All rights reserved.

14

Generic Modeling

Summary
Practice Guide
The link for the lesson practice guide can be found in
the course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

15

Introduction to Relational Database


Concepts

Copyright 2011, Oracle. All rights reserved.

Introduction to Relational Database Concepts

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define a primary key
Define a foreign key
Define a column-integrity rule
Identify row, column, primary key, unique key, and
foreign key given a diagram of a table containing these
elements
Identify violations of data-integrity rules

Copyright 2010, Oracle. All rights reserved.

Introduction to Relational Database Concepts

Why Learn It?


Purpose
The conceptual data model will be transformed into a
relational database design. This means that our entities,
attributes, relationships, and unique identifiers will be
translated into objects in a relational database.
Compare this to a clothing designer that is taking their
design from paper and implementing it with fabric. The
designer needs to understand how to sew the designs just
like you will need to understand the structure of relational
database objects.

Copyright 2010, Oracle. All rights reserved.

Introduction to Relational Database Concepts

Tell Me / Show Me
Relational Database Illustrated
A relational database is a database that is seen by the user as
a collection of two-dimensional tables.

The table below contains employee data.


EMPLOYEES (table name)

Row

EMPLOYEE_ID

FIRST_NAME

LAST_NAME

DEPARTMENT_ID

100

Steven

King

90

101

Neena

Kochhar

90

102

Lex

De Haan

90

200

Jennifer

Whalen

10

205

Shelley

Higgins

110

Column
Copyright 2010, Oracle. All rights reserved.

Introduction to Relational Database Concepts

Tell Me / Show Me
Language to Access Data
Structured query language (SQL) allows us to access data
in relational databases in an efficient way. Instead of going
through each row to find the record for employee number
200, we use the following SQL statement:
SELECT last_name, department_id
FROM employees
WHERE employee_id = 200;

You can see the result of this statement on the next slide.

Copyright 2010, Oracle. All rights reserved.

Introduction to Relational Database Concepts

Tell Me / Show Me
SQL Query Illustrated
EMPLOYEES (table name)
EMPLOYEE_ID

FIRST_NAME

LAST_NAME

DEPARTMENT_ID

100

Steven

King

90

101

Neena

Kochhar

90

102

Lex

De Haan

90

200

Jennifer

Whalen

10

205

Shelley

Higgins

110

SELECT last_name, department_id


FROM employees
WHERE employee_id = 200;
LAST_NAME

DEPARTMENT_ID

Whalen

10

Copyright 2010, Oracle. All rights reserved.

Introduction to Relational Database Concepts

Tell Me / Show Me
Specific SQL Query
To find all the employees in department number 90, we
write a different SQL statement:
SELECT *
FROM employees
WHERE department_id = 90;

Again, you can see the result on the next slide.

Copyright 2010, Oracle. All rights reserved.

Introduction to Relational Database Concepts

Tell Me / Show Me
Specific SQL Query (continued)
EMPLOYEES (table name)
EMPLOYEE_ID

FIRST_NAME

LAST_NAME

...

DEPARTMENT_ID

100

Steven

King

...

90

101

Neena

Kochhar

...

90

102

Lex

De Haan

...

90

200

Jennifer

Whalen

...

10

205

Shelley

Higgins

...

110

SELECT *
FROM employees
WHERE department_id = 90;
EMPLOYEES (table name)
EMPLOYEE_ID

FIRST_NAME

LAST_NAME

...

DEPARTMENT_ID

100

Steven

King

...

90

101

Neena

Kochhar

...

90

102

Lex

De Haan

...

90

Copyright 2010, Oracle. All rights reserved.

Introduction to Relational Database Concepts

Tell Me / Show Me
Primary Key
A primary key (PK)
is a column or set
of columns that
uniquely identifies
each row in a
table.

ACCOUNTS
BANK_NO

ACCT_NO

BALANCE

DATE_OPENED

104

75760

12,0050.00

21-OCT-89

104

77956

100.10

105

89570

55,775.00

15-JAN-85

103

55890

15,001.85

10-MAR-91

105

75760

5.00

22-SEP-03

Primary Key

EMPLOYEES
EMPLOYEE_ID

FIRST_NAME

LAST_NAME

...

DEPARTMENT_ID

100

Steven

King

...

90

101

Neena

Kochhar

...

90

102

Lex

De Haan

90

200

Jennifer

Whalen

...
...

205

Shelley

Higgins

...

110

10

Primary Key
Copyright 2010, Oracle. All rights reserved.

Introduction to Relational Database Concepts

Tell Me / Show Me
Primary Key Rules
Each table should
have a primary key,
and a primary key
must be unique.
No part of the
primary key can be
null.

ACCOUNTS

BANK_NO

ACCT_NO

BALANCE

DATE_OPENED

104

75760

12,0050.00

21-OCT-89

104

77956

100.10

105

89570

55,775.00

15-JAN-85

103

55890

15,001.85

10-MAR-91

105

75760

5.00

22-SEP-03

Primary Key

EMPLOYEES
EMPLOYEE_ID

FIRST_NAME

LAST_NAME

...

DEPARTMENT_ID

100

Steven

King

...

90

101

Neena

Kochhar

...

90

102

Lex

De Haan

90

200

Jennifer

Whalen

...
...

205

Shelley

Higgins

...

110

Primary Key

Copyright 2010, Oracle. All rights reserved.

10

10

Introduction to Relational Database Concepts

Tell Me / Show Me
Primary Key Candidates
A table can have more than one column or combination of
columns that could serve as the tables primary key. Each of
these is called a "candidate" key.
MEMBERS
MEMBER_ID

LAST_NAME

FIRST_NAME

PAYROLL_ID

100

SMITH

DANA

21215

310

ADAMS

TYLER

59877

210

CHEN

LAWRENCE

1101

405

GOMEZ

CARLOS

52

378

LOUNGANI

NEIL

90386

Candidate Key

Candidate Key

Copyright 2010, Oracle. All rights reserved.

11

Introduction to Relational Database Concepts

Tell Me / Show Me
Choose a Candidate Key
Select one candidate key to be the primary key for the table.
The other candidates become alternate keys (or unique
keys).
MEMBERS
MEMBER_ID

LAST_NAME

FIRST_NAME

PAYROLL_ID

100

SMITH

DANA

21215

310

ADAMS

TYLER

59877

210

CHEN

LAWRENCE

1101

405

GOMEZ

CARLOS

52

378

LOUNGANI

NEIL

90386

Alternate or
Unique Key (UK)

Primary Key

Copyright 2010, Oracle. All rights reserved.

12

Introduction to Relational Database Concepts

Tell Me / Show Me
Foreign Key
A foreign key
(FK) is a column
or combination
of columns in
one table that
refers to a
primary key in
the same table
or another table.

Primary Key

Foreign Key

EMPLOYEES
EMPLOYEE_ID

FIRST_NAME

LAST_NAME

DEPARTMENT_ID

100

Steven

King

90

101

Neena

Kochhar

90

102

Lex

De Haan

90

200

Jennifer

Whalen

10

205

Shelley

Higgins

110

refers to
DEPARTMENTS
DEPARTMENT_ID DEPARTMENT_NAME

10

Administration

20

Marketing

50

Shipping

Primary Key

Copyright 2010, Oracle. All rights reserved.

13

Introduction to Relational Database Concepts

Tell Me / Show Me
Foreign Key Rules
If a foreign key is part of a primary key, that FK cannot be
NULL.
Primary Key

Primary Key

SHELF_NO

BOOK_NO

SHELF_NO

SHELF_NO

A6

106

A6

LITTLE WOMEN

A8

15

A8

TALE OF TWO CITIES

7987

B24

HARRY POTTER

15

Q35

LEARN TO SPEAK
SPANISH

B24
Q35
SHELVES

BOOKS

Foreign
refers to
Copyright 2010, Oracle. All rights reserved.

14

Introduction to Relational Database Concepts

Tell Me / Show Me
Column Integrity
A column must
contain only
values consistent
with the defined
data format of the
column.

ACCOUNTS
BANK_NO

ACCT_NO

BALANCE

DATE_OPENED

104

75760

12,0050.00

21-OCT-89

104

77956

100.10

105

89570

55,775.00

15-JAN-85

103

55890

15,001.85

10-MAR-91

105

75760

5.00

22-SEP-03

ACCOUNTS Table Definition


Column Name

Data Type

Optionality

BANK_NO

Number (5)

Not null

ACCT_NO

Number (8)

Not null

BALANCE

Number (12,2)

Not null

DATE_OPENED

Date

Copyright 2010, Oracle. All rights reserved.

15

Introduction to Relational Database Concepts

Tell Me / Show Me
Summary of Data-Integrity Rules
Data-integrity rules (also known as constraints) define the
relationally correct state for a database. Data-integrity rules
ensure that users can perform only those operations that
leave the database in a correct, consistent state.
CONSTRAINT TYPE

EXPLANATION

EXAMPLE

Entity Integrity

A primary key must be unique, and no


part of the primary key can be null

The column emp_no in the


EMPLOYEES table cannot be null

Referential Integrity

A foreign key must match an existing


primary key value (or else be null)

The value in the dept_no column of


the EMPLOYEES table must match a
value in the dept_no column in the
DEPARTMENTS table

Column Integrity

A column must contain only values


consistent with the defined data format
of the column

The value in the balance column of


the ACCOUNTS table must be
numeric

User-Defined Integrity

The data stored in a database must


comply with the rules of the business

If the value in the balance column of


the ACCOUNTS table is below 1.00,
we must send a letter to the account
owner ( this will need extra
programming to enforce)

Copyright 2010, Oracle. All rights reserved.

16

Introduction to Relational Database Concepts

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Candidate key
Column
Foreign key
Primary key
Relational database
Row
Unique key

Copyright 2010, Oracle. All rights reserved.

17

Introduction to Relational Database Concepts

Summary
Objectives Summarized
In this lesson, you have learned to:
Define a primary key
Define a foreign key
Define a column-integrity rule
Identify row, column, primary key, unique key, and
foreign key given a diagram of a table containing
these elements
Identify violations of data-integrity rules

Copyright 2010, Oracle. All rights reserved.

18

Introduction to Relational Database Concepts

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

19

Basic Mapping: The Transformation


Process

Copyright 2011, Oracle. All rights reserved.

Basic Mapping: The Transformation Process

What Will I Learn?


Objectives
In this lesson, you will learn to:

Distinguish entity relationship models from database


models
Describe the terminology mapping between a
conceptual model and a relational database model
Understand and apply the Oracle naming conventions
for tables and columns used in relational models
Transform an entity into a table diagram

Copyright 2010, Oracle. All rights reserved.

Basic Mapping: The Transformation Process

Why Learn It?


Purpose
When you design a house, you eventually would like to see
the house built. Even if you dont do the actual construction,
you will need to understand the terms used by the builders in
order to help them take your design and make it a reality.
The initial database design can be used for further
discussion between designers, database administrators, and
application developers.

Copyright 2010, Oracle. All rights reserved.

Basic Mapping: The Transformation Process

Tell Me / Show Me
Review of Relational Tables
A table is a simple structure in which data is organized and stored.
In the example below, the EMPLOYEES table is used to store
employees information.
Table: EMPLOYEES
columns
EMPLOYEE_ID

LAST_NAME

FIRST_NAME

DEPARTMENT_ID

PAYROLL_ID

NICKNAME

100

SMITH

DANA

10

21215

Dana

310

ADAMS

TYLER

15

59877

Ty

210

CHEN

LAWRENCE

10

1101

Larry

405

GOMEZ

CARLOS

10

52

Chaz

378

LOUNGANI

NEIL

22

90386

Neil

rows

Primary Key
Column (PK)

Foreign Key
Column (FK)

Copyright 2010, Oracle. All rights reserved.

Unique Key
Column (UK)

Basic Mapping: The Transformation Process

Tell Me / Show Me
Review of Relational Tables (continued)
Tables have columns and rows. In the example, below, each row
describes an occurrence of an employee. Each column is used to
store a specific type of value, such as employee number, last
name, and first name.
Table: EMPLOYEES
columns
EMPLOYEE_ID

LAST_NAME

FIRST_NAME

DEPARTMENT_ID

PAYROLL_ID

NICKNAME

100

SMITH

DANA

10

21215

Dana

310

ADAMS

TYLER

15

59877

Ty

210

CHEN

LAWRENCE

10

1101

Larry

405

GOMEZ

CARLOS

10

52

Chaz

378

LOUNGANI

NEIL

22

90386

Neil

rows

Primary Key
Column (PK)

Foreign Key
Column (FK)
Copyright 2010, Oracle. All rights reserved.

Unique Key
Column (UK)
5

Basic Mapping: The Transformation Process

Tell Me / Show Me
Review of Relational Tables (continued)
The employee_id column is a primary key. Every employee has
a unique identification number in this table. The value in the
primary key column distinguishes each individual row.
Table: EMPLOYEES
columns
EMPLOYEE_ID

LAST_NAME

FIRST_NAME

DEPARTMENT_ID

PAYROLL_ID

NICKNAME

100

SMITH

DANA

10

21215

Dana

310

ADAMS

TYLER

15

59877

Ty

210

CHEN

LAWRENCE

10

1101

Larry

405

GOMEZ

CARLOS

10

52

Chaz

378

LOUNGANI

NEIL

22

90386

Neil

rows

Primary Key
Column (PK)

Foreign Key
Column (FK)

Copyright 2010, Oracle. All rights reserved.

Unique Key
Column (UK)

Basic Mapping: The Transformation Process

Tell Me / Show Me
Review of Relational Tables (continued)
The payroll_id is a unique key. This means that the system
does not allow two rows with the same payroll_id.
Table: EMPLOYEES
columns
EMPLOYEE_ID

LAST_NAME

FIRST_NAME

DEPARTMENT_ID

PAYROLL_ID

NICKNAME

100

SMITH

DANA

10

21215

Dana

310

ADAMS

TYLER

15

59877

Ty

210

CHEN

LAWRENCE

10

1101

Larry

405

GOMEZ

CARLOS

10

52

Chaz

378

LOUNGANI

NEIL

22

90386

Neil

rows

Primary Key
Column (PK)

Foreign Key
Column (FK)

Copyright 2010, Oracle. All rights reserved.

Unique Key
Column (UK)

Basic Mapping: The Transformation Process

Tell Me / Show Me
Review of Relational Tables (continued)
The foreign key column refers to a row in another table. In this
example, the department_id refers to a row in the
DEPARTMENTS table.
Table: EMPLOYEES
columns
EMPLOYEE_ID

LAST_NAME

FIRST_NAME

DEPARTMENT_ID

PAYROLL_ID

NICKNAME

100

SMITH

DANA

10

21215

Dana

310

ADAMS

TYLER

15

59877

Ty

210

CHEN

LAWRENCE

10

1101

Larry

405

GOMEZ

CARLOS

10

52

Chaz

378

LOUNGANI

NEIL

22

90386

Neil

rows

Primary Key
Column (PK)

Foreign Key
Column (FK)

Copyright 2010, Oracle. All rights reserved.

Unique Key
Column (UK)

Basic Mapping: The Transformation Process

Tell Me / Show Me
Review of Relational Tables (continued)
We know that Dana Smith works in department 10. If we wanted to
know more about Dana Smiths department, we would look for the
row in the DEPARTMENTS table that has deptartment_id = 10.

Table: EMPLOYEES
columns
EMPLOYEE_ID

LAST_NAME

FIRST_NAME

DEPARTMENT_ID

PAYROLL_ID

NICKNAME

100

SMITH

DANA

10

21215

Dana

310

ADAMS

TYLER

15

59877

Ty

210

CHEN

LAWRENCE

10

1101

Larry

405

GOMEZ

CARLOS

10

52

Chaz

378

LOUNGANI

NEIL

22

90386

Neil

rows

Primary Key
Column (PK)

Foreign Key
Column (FK)
Copyright 2010, Oracle. All rights reserved.

Unique Key
Column (UK)
9

Basic Mapping: The Transformation Process

Tell Me / Show Me
Transforming Conceptual To Physical
The conceptual model (ER diagram) is transformed into a physical
model. The physical implementation will be a relational database.
EMPLOYEE
# employee id
* first name
* last name
* payroll id
o nickname

Conceptual Model (ERD)


Transformation
process

DEPARTMENT
# department id
* department name

Physical Implementation: Relational Database


DEPARTMENTS (DPT)

EMPLOYEES (EPE)
Key type

Optionality

Column name

Key type

Optionality

Column name

pk

employee_id

pk

department_id

uk

payroll_id

department_name

last_name

first_name

nickname

department_id

fk

Copyright 2010, Oracle. All rights reserved.

10

Basic Mapping: The Transformation Process

Tell Me / Show Me
Terminology Mapping
Changing from analysis (conceptual model) to design (physical
implementation) also means changing terminology:
An entity becomes a table.
An instance becomes a row.
An attribute becomes a column.
A primary unique identifier becomes
a primary key.
A secondary unique identifier
ANALYSIS
DESIGN
becomes a unique key.
ER Diagram
Physical Design
A relationship is transformed
Table
Entity
into a foreign-key column and
Row
Instance
a foreign key constraint.
Column
Attribute
Primary UID
Secondary UID
Relationship
Copyright 2010, Oracle. All rights reserved.

Primary Key
Unique Key
Foreign Key
11

Basic Mapping: The Transformation Process

Tell Me / Show Me
Table Diagram
Notations
The first row of the table
diagram contains the
table name and the short
name.

TABLE NAME (short name)


Key Type (pk, uk, fk)

Optionality (*, o)

Column Name

The Key Type column


should contain values of
pk for the primary key,
uk for the unique key,
and fk for the foreignkey column. It will be
blank if the column is not
a part of any key.

Copyright 2010, Oracle. All rights reserved.

12

Basic Mapping: The Transformation Process

Tell Me / Show Me
Table Diagram
Notations (continued)
The Optionality column
must contain * if the
column is mandatory and
o if it is optional. This is
similar to the entity
diagram.

TABLE NAME (short name)


Key Type (pk, uk, fk)

Optionality (*, o)

Column Name

The third column is for


the column name.

Copyright 2010, Oracle. All rights reserved.

13

Basic Mapping: The Transformation Process

Tell Me / Show Me
Naming Conventions
for Tables and
Columns
The table name is the
plural of the entity
name.
Example: STUDENT
becomes STUDENTS

STUDENTS
STUDENT

Key Type

Optionality

Column Name

# id

pk

id

* first name

first_name

* last name

last_name

* street address

str_addr

* city

city

* state

state

p_code

dob

* postal code
* date of birth

Copyright 2010, Oracle. All rights reserved.

14

Basic Mapping: The Transformation Process

Tell Me / Show Me
Naming Conventions
for Tables and
Columns (continued)
Column names are
identical to the
attribute names
except that special
characters and
spaces are replaced
with underscores.
Column names often
use more
abbreviations than
attribute names.
Example: first name
becomes first_name,
or fname

STUDENTS
STUDENT

Key Type

Optionality

Column Name

# id

pk

id

* first name

first_name

* last name

last_name

str_addr

city

state

p_code

dob

* street address

* city
* state
* postal code
* date of birth

Copyright 2010, Oracle. All rights reserved.

15

Basic Mapping: The Transformation Process

Tell Me / Show Me
Table Short Names
A unique short name for every table is useful in the naming of
foreign-key columns. One possible way to make these short names is
based on the following rules:
For entity names of more than one word, take the:
First character of the first word
First character of the second word
Last character of the last word
Example: JOB ASSIGNMENT gets a short name of JAT
PRIVATE HOMES (PHE)
PRIVATE HOME
# id
* address
o comments

Key Type

Optionality

Column Name

pk

id

address

comments

Copyright 2010, Oracle. All rights reserved.

16

Basic Mapping: The Transformation Process

Tell Me / Show Me
Table Short Names (continued)
For entity names of one word but more than one syllable, take the:
First character of the first syllable
First character of the second syllable
Last character of the last syllable
Example: EMPLOYEE gets a short name of EPE and CLIENT gets a
short name of CET
CLIENTS (CET)
CLIENT
# number
* first name
* last name
* phone number
o email address

Key Type

Optionality

Column Name

pk

client_num

first_name

last_name

phone_num

email_addr

Copyright 2010, Oracle. All rights reserved.

17

Basic Mapping: The Transformation Process

Tell Me / Show Me
Table Short Names (continued)
For entity names of one syllable but more than one character:
First character
Second character
Last character
Example: FLIGHT gets a short name of FLT

THEMES (THE)
THEME
# code
* description

Key Type

Optionality

Column Name

pk

code

description

Copyright 2010, Oracle. All rights reserved.

18

Basic Mapping: The Transformation Process

Tell Me / Show Me
Naming Restrictions with Oracle
Table and column names:
Must start with a letter
Can contain up to 30 alphanumeric characters
Cannot contain spaces or special characters such as !,
but $, #, and _ are permitted.

Table names must be unique within one user account in the


Oracle database.
Column names must be unique within a table.

Copyright 2010, Oracle. All rights reserved.

19

Basic Mapping: The Transformation Process

Tell Me / Show Me
Naming Restrictions with Oracle (continued)
Some words have a special meaning in the Oracle database and
in the SQL programming language. These are called reserved
words. It is best to avoid using these as names for your tables and
columns. Some common examples of Oracle reserved words are:
TABLE
NUMBER
SEQUENCE
ORDER
VALUES
LEVEL
TYPE
A complete list can be found on Technet. (otn.oracle.com)

Copyright 2010, Oracle. All rights reserved.

20

Basic Mapping: The Transformation Process

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Transform
Map
Reserved word

Copyright 2010, Oracle. All rights reserved.

21

Basic Mapping: The Transformation Process

Summary
Objectives Summarized
In this lesson, you have learned to:
Distinguish entity relationship models from database
models
Describe the terminology mapping between a conceptual
model and a relational database model
Understand and apply the Oracle naming conventions for
tables and columns used in relational models
Transform an entity into a table diagram

Copyright 2010, Oracle. All rights reserved.

22

Basic Mapping: The Transformation Process

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

23

Relationship Mapping

Copyright 2011, Oracle. All rights reserved.

Relationship Mapping

What Will I Learn?


Objectives
In this lesson, you will learn to:
Apply the rule of relationship mapping to correctly
transform 1:M and barred relationships
Apply the rule of relationship mapping to correctly
transform M:M relationships
Transform 1:1 relationships
Apply the rule of relationship mapping to correctly
transform relationships in an arc

Copyright 2010, Oracle. All rights reserved.

Relationship Mapping

Why Learn It?


Purpose
What if you were building a house for someone? You buy all
the materials wood, paint, doors, windows, nails, screws,
etc. but you do not know how to put all the pieces together.
You dont know how many rooms there should be, where the
windows should be placed, how the doors should be oriented,
or what color each room should be painted. You could build a
house in such a manner, but if you do not have a plan or
blueprint identifying how the pieces of the house go together,
the final product may not be the house that the customer has
in mind.

Copyright 2010, Oracle. All rights reserved.

Relationship Mapping

Why Learn It?


Purpose (continued)
Relationships are mapped to foreign keys that allow tables to
reference each other. Foreign keys enable users to access
related information from other tables. If we dont map
relationships, we just have a lot of standalone tables containing
information that cant be related to the rest of the database.
Just like a blueprint serves as a design for a house, mapping
relationships to relational database structures is part of creating
the first-cut database design that will serve as the basis for
further discussion among designers, developers, and database
administrators.

Copyright 2010, Oracle. All rights reserved.

Relationship Mapping

Tell Me / Show Me
Rules for Relationships
A relationship creates one or more foreign-key columns in
the table at the many side.
We use the short name of the table to name the foreign-key
column. In the example on the next page, the foreign-key
column in the EMPLOYEES table is dpt_id for the
relationship with DEPARTMENT and epe_id for the
recursive relationship.
The foreign-key column is mandatory or optional,
depending on whether or not the relationship is required. In
the example, dpt_id is mandatory and epe_id is optional.

Copyright 2010, Oracle. All rights reserved.

Relationship Mapping

Tell Me / Show Me
Rules for Relationships Illustrated
managed by
EMPLOYEE
# id
* name
the manager * address
of * birth date

EMPLOYEES (EPE)

DEPARTMENT
# id
* name

belong to
composed of

DEPARTMENTS (DPT)

Key Type

Optionality

Column
Name

Key Type

Optionality

Column
Name

pk

id

pk

id

name

uk

name

address

birth_date

fk1

dpt_id

fk2

epe_id

foreign key refers to

foreign key refers to

Copyright 2010, Oracle. All rights reserved.

Relationship Mapping

Tell Me / Show Me
Mapping of Mandatory Relationship at the One Side
Relationships that are mandatory on the one side, or mandatory on
both sides, are mapped exactly the same way as a relationship that
is optional on the one side. The ER model is rich enough to capture
optionality at both ends of the relationship. However, the relational
model is limited in that a foreign-key constraint can enforce a
mandatory relationship only at the many end.
In the following example, the relational model cannot enforce that a
BAND must be composed of at least one MUSICIAN. The
optionality at the one end will have to be implemented through
additional programming.

Copyright 2010, Oracle. All rights reserved.

Relationship Mapping

Tell Me / Show Me
Enforcing Optionality
MUSICIAN
# id
* name
o instrument

a member of

composed of

MUSICIANS (MSN)

BANDS (BAD)

Key type

Optionality

Column
name

pk

id

name

instrument

bad_id

fk

BAND
# id
* name

Foreign
key
refers
to

Key type

Optionality

Column
name

pk

id

name

Copyright 2010, Oracle. All rights reserved.

Relationship Mapping

Tell Me / Show Me
Mapping of Nontransferable Relationships
A nontransferable relationship in the conceptual model
means that the foreign-key column in the database table
cannot be updated. The foreign-key constraint cannot
enforce this in the database. Additional programming will be
needed to make sure that the database follows this business
rule. It is important to document these rules so that the team
remembers to write the appropriate code and enforce this
business rule.

Copyright 2010, Oracle. All rights reserved.

Relationship Mapping

Tell Me / Show Me
Enforcing Nontransferable Relationships
PAY CHECK
# id
* pay period

EMPLOYEE
# id
* name

issued to
the recipient of

PAYCHECKS (PCK)
Key Type

Optionality

Column Name

pk

id

pay_period

epe_id

fk

The value in this


foreign-key
column cannot
be changed

Copyright 2010, Oracle. All rights reserved.

10

Relationship Mapping

Tell Me / Show Me
Mapping of Barred Relationships
A barred relationship is mapped to a foreign-key column
on the many side, just like any other M:1 relationship. In
this case, the foreign-key column plays a double role,
because it is also part of the primary key.
In the example, bak_number is a foreign-key column in
ACCOUNTS that refers to the primary key of BANKS. It is
also part of the primary key of ACCOUNTS.

Copyright 2010, Oracle. All rights reserved.

11

Relationship Mapping

Tell Me / Show Me
Mapping of Barred Relationships (continued)
ACCOUNT
# number
* balance
* date opened

located in

the location of

BANK
# number
* name

ACCOUNTS (ACT)
Key Type

Optionality

Column Name

pk

act_nbr

balance

date_opened

bak_nbr

pk,fk

refers
to

BANKS (BAK)
Key Type

Optionality

Column Name

pk

bank_number
name

Copyright 2010, Oracle. All rights reserved.

12

Relationship Mapping

Tell Me / Show Me
Cascade Barred Relationships
Hierarchies can lead to cascade barred relationships, where
the UID of the entity at the top of the hierarchy is carried all
the way down to the UID of the entity at the bottom of the
hierarchy. In the example, the UID of ROOM is composed of
the ROOM number, SUITE number, FLOOR number, and
BUILDING id. This is represented by the barred relationships.
When this is mapped to a relational model, it can result in
very long foreign-key column names, as they use the short
names of the originating tables as a prefix. The suggested
convention is never to use more than two table prefixes. In
the following example, the foreign-key column in ROOMS that
comes all the way from BUILDINGS is named sue_bdg_id,
instead of sue_flr_bdg_id.
Copyright 2010, Oracle. All rights reserved.

13

Relationship Mapping

Tell Me / Show Me
Cascade Barred Relationships (continued)
located within

located within

ROOM
# number

SUITE
# number
o tenant
the location of

ROOMS (ROM)

located within

BUILDING
# id
* address

FLOOR
# number

the location of

the location of

SUITES (SUE)

pk

rom_nbr

pk

sue_nbr

pk, fk

sue_nbr

pk, fk

flr_nbr

pk, fk

sue_flr_nbr

pk, fk

flr_bdg_id

pk, fk

sue_bdg_id

tenant

FLOORS (FLR)

BUILDINGS (BDG)

pk

flr_nbr

pk

pk, fk

bdg_id

id

address

Copyright 2010, Oracle. All rights reserved.

14

Relationship Mapping

Tell Me / Show Me
Cascade Barred Relationship Illustrated
Sample data for each table illustrates the cascade barred
relationships.
SUITES sue_nbr
BUILDINGS

id

address

100

40 Potters Lane

201

57G Maricopa Way

FLOORS flr_nbr

flr_nbr

flr_bdg

15

100

25

100

5E

201

7B

201

bdg_id

100

100

201

201

ROOMS rom_nbr

sue_nbr

sue_flr_nbr

sue_bdg_id

15

100

15

100

7B

201

Copyright 2010, Oracle. All rights reserved.

15

Relationship Mapping

Tell Me / Show Me
Mapping Many-to-Many Relationships
A M:M relationship is resolved with an intersection entity,
which maps to an intersection table. This intersection table
will contain foreign-key columns that refer to the originating
tables.
In the example, REVIEWS contains all the combinations that
exist between a CRITIC and a MOVIE.

Copyright 2010, Oracle. All rights reserved.

16

Relationship Mapping

Tell Me / Show Me
Mapping Many-to-Many Relationships (continued)
REVIEW
* rating

CRITIC
# id
* name

MOVIE
# id
* title

CRITICS (CTC)
pk

REVIEWS (RVW)

id

name

MOVIES (MVE)
pk

id

title

Key Type

Optionality

Column Name

pk, fk1

ctc_id

pk, fk2

mve_id

rating

Copyright 2010, Oracle. All rights reserved.

17

Relationship Mapping

Tell Me / Show Me
Mapping Many-to-Many Relationships (continued)
When transforming a 1:1 relationship, you create a foreign
key and a unique key. All columns of this foreign key are
also part of the unique key.
If the relationship is mandatory on one side, the foreign
key is created in the corresponding table. In the example,
bcp_code is the foreign-key column in SODA_BOTTLES
that refers to the primary key of BOTTLE_CAPS.
Bcp_code would also be unique within the
SODA_BOTTLES table.

Copyright 2010, Oracle. All rights reserved.

18

Relationship Mapping

Tell Me / Show Me
Mapping Many-to-Many Relationships
SODA BOTTLE
# id
* name

sealed with

SODA_BOTTLES (SBE)
pk

fk, uk

id

name

bcp_code

the sealer for

BOTTLE CAP
# code
* description

BOTTLE_CAPS (BCP)
pk

code

description

Copyright 2010, Oracle. All rights reserved.

19

Relationship Mapping

Tell Me / Show Me
Optional Many-to-Many
If the relationship is optional on both sides, you can choose
which table gets the foreign key. There are no absolute rules,
but here are some guidelines:
Implement the foreign key in the table with fewer rows to
save space.
Implement the foreign key where it makes more sense
for the business.
In the example, a car-rental agency would be more
concerned about cars than spaces, so it makes sense to put
the foreign key in CARS. However, in a parking-lot business,
the main object is the parking space. Therefore, it would
make sense to put the foreign key in SPACES.
Copyright 2010, Oracle. All rights reserved.

20

Relationship Mapping

Tell Me / Show Me
Business Rules for Optional Many-to-Many
CAR
# license plate
* model

SPACE
# id
* description

parked in
the location for

Car-Rental Business
CARS (CAR)
pk

fk, uk

SPACES (SPE)

lic_plate

model

spe_id

pk

id

description

Parking-Lot Business
CARS (CAR)
pk

SPACES (SPE)

lic_plate

model

pk

fk, uk

id

description

car_lic_plate

Copyright 2010, Oracle. All rights reserved.

21

Relationship Mapping

Tell Me / Show Me
Enforcing Many-to-One
If the relationship is mandatory at both ends, you have the
same limitation in the database as a M:1 relationship that is
mandatory at the one end. Therefore, you would need to
write additional code to enforce it.

Copyright 2010, Oracle. All rights reserved.

22

Relationship Mapping

Tell Me / Show Me
Mapping Arcs
The entity that has the arc will map to a table that contains
foreign keys from the tables on the one end of the
relationships.
Note that even if the relationships in the arc are mandatory on
the many side, the resulting foreign keys have to be optional
(because one of them will always be blank).

Copyright 2010, Oracle. All rights reserved.

23

Relationship Mapping

Tell Me / Show Me
Mapping Arcs (continued)
PUBLIC SPACE
# id
* address
* rental fee
o comments

held at
EVENT
# id
* name
* date
* cost
o description

the venue for


held at
the venue for

PUBLIC_SPACES (PSE)

EVENTS (EVT)
pk

PRIVATE HOME
# id
* address
o comments

pk

id

name

date

cost

description

fk1

pse_id

fk2

phe_id

id

address

rental_fee

comments

PRIVATE HOMES (PHE)


pk

id

address

comments

Copyright 2010, Oracle. All rights reserved.

24

Relationship Mapping

Tell Me / Show Me
Mapping Arcs (continued)
Since the arc represents exclusive relationships, additional
code is needed to enforce that only one of the foreign keys
has a value for every row in the table. A check constraint
stored in the database can easily do this. In the example, the
code for the check constraint would look like this:
CHECK (pse_id is not null AND phe_id is null)
OR (pse_id is null AND phe_id is not null)
If the relationships were fully optional, you would add:
OR (pse_id is null AND phe_id is null)

Copyright 2010, Oracle. All rights reserved.

25

Relationship Mapping

Tell Me / Show Me
Mapping Arcs (continued)
id

address

rental fee

comments

900 Chestnut St

100.00

No elevator

10

201 Union Highway

78.00

Church
basement

Sample data for PUBLIC_SPACES

Sample data for PRIVATE_HOMES


id

address

15

4 Via Maria

20

677 Third Street

comments

Large projection TV

Sample data for EVENTS


id

name

date

cost

description

42

Jones
reception

05 June

500

48

Morales
party

08 July

750

Surprise 40th

50

Brennan
dinner

12 July

400

Catered

pse_id

phe_id

6
10

Copyright 2010, Oracle. All rights reserved.

20

26

Relationship Mapping

Tell Me / Show Me
Mapping Arcs (continued)
The code checks that if there is a value for the public space
id (pse_id), then the column for private home id (phe_id)
must be empty. Conversely, if the public space id is NULL,
then there must be a value for the private home id. In a fully
optional relationship, additional code allows both the public
space id and the private home id to be null (the event is not
held at any venue).

Copyright 2010, Oracle. All rights reserved.

27

Relationship Mapping

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Nontransferable relationship
Cascade barred relationship
Intersection entity

Copyright 2010, Oracle. All rights reserved.

28

Relationship Mapping

Summary
Objectives
In this lesson, you have learned to:
Apply the rule of relationship mapping to correctly
transform 1:M and barred relationships
Apply the rule of relationship mapping to correctly
transform M:M relationships
Transform 1:1 relationships
Apply the rule of relationship mapping to correctly
transform relationships in an arc

Copyright 2010, Oracle. All rights reserved.

29

Relationship Mapping

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

30

Subtype Mapping

Copyright 2011, Oracle. All rights reserved.

Subtype Mapping

What Will I Learn?


Objectives
In this lesson, you will learn to:
State and apply the table, column, identifiers,
relationship, and integrity constraint rules for mapping
supertype implementations
State and apply the table, column, identifiers,
relationship, and integrity constraint rules for mapping
subtype implementations
State and apply the table, column, identifiers,
relationship, and integrity constraint rules for mapping
supertype and subtype arc implementations

Copyright 2010, Oracle. All rights reserved.

Subtype Mapping

Why Learn It?


Purpose
A carpenter who is building your dream house may know that
you will use different types of light bulbs all around the
house. However, if you do not provide information on where
certain types of light bulbs should be installed, you could end
up with an overly bright bedroom and a dimly lit kitchen!
Mapping supertypes and subtypes makes sure that the right
information gets stored with each type.

Copyright 2010, Oracle. All rights reserved.

Subtype Mapping

Tell Me / Show Me
Supertype Implementation: Single Table
This choice produces a single table for the implementation of
the supertype entity and its subtypes. This is also called
"single-table (or one-table) implementation."
Rules
1. Tables: Only one table is created, independent of the
number of subtypes.
2. Columns: The single table gets a column for all the
attributes of the supertype, with the original optionality.

Copyright 2010, Oracle. All rights reserved.

Subtype Mapping

Tell Me/ Show Me


Supertype Implementation: Single Table (continued)
The table also gets a column for each attribute belonging to
the subtype, but the columns all become optional.
Additionally, a mandatory column should be created to act as
a discriminator column to distinguish between the different
subtypes of the entity. The value it can take is from the set of
all the subtype short names (FTE, PTE, OTR in the
example). This discriminator column is usually called
<table_short_name>_type, in the example epe_type

Copyright 2010, Oracle. All rights reserved.

Subtype Mapping

Tell Me / Show Me
Supertype Implementation: Single Table
(continued)

DEPARTMENTS (DPT)
pk

id

AGENCIES (AGY)
pk

id

EMPLOYEES (EPE)

the manager of
EMPLOYEE
# id
* first name
* last name
FULL TIME
* salary
PART TIME
* hourly rate

Key Type

Optionality

Column
Name

pk

id

first_name

last_name

salary

hourly_rate

fk1

dpt_id

fk2

agy_id

epe_type

mgr_id

managed by
assigned to
the home for

employed by
the source of

DEPARTMENT
# id

AGENCY
# id

fk3

Copyright 2010, Oracle. All rights reserved.

Subtype Mapping

Tell Me / Show Me
Supertype Implementation: Single Table (continued)
Rules
3. Identifiers: Unique identifiers transform into primary and unique
keys.
4. Relationships: Relationships at the supertype level transform
as usual. Relationships at subtype level are implemented as
optional foreign-key columns.
5. Integrity constraints: A check constraint is needed to ensure
that for each particular subtype, all columns that come from
mandatory attributes are not null.

Copyright 2010, Oracle. All rights reserved.

Subtype Mapping

Tell Me / Show Me
Supertype Implementation: Single Table (continued)
In the ER model, salary is mandatory for full-time
employees and hourly rate is mandatory for part-time
employees. When the EMPLOYEE supertype is
implemented as a single table in the relatonal model, these
attributes become optional. A check constraint is needed to
enforce the business rules modeled in the ERD.

Copyright 2010, Oracle. All rights reserved.

Subtype Mapping

Tell Me/ Show Me


Supertype Implementation: Single Table (continued)
In the example, the code for the check constraint would look
like this:
CHECK (epe_type = FTE and salary is not null and
hourly_rate is null and agy_id is null)
OR (epe_type = PTE and salary is null and hourly_rate is
not null and agy_id is not null)

Copyright 2010, Oracle. All rights reserved.

Subtype Mapping

Tell Me/ Show Me


Supertype Implementation: Single Table (continued)
The code checks that if it is a full-time employee (epe_type
= FTE), then there must be a value in the salary column
and the hourly_rate and agy_id columns must be empty.
Conversely, if it is a part-time employee (epe_type =
PTE), then there must be value in hourly_rate, and an
agy_id, but salary must be left blank.

Copyright 2010, Oracle. All rights reserved.

10

Subtype Mapping

Tell Me / Show Me
Supertype Implementation: Single Table
(continued)
Sample Data for EMPLOYEES
id

first_name

last_name

salary

2000

Joan

Merrick

50000

111

Sylvia

Patakis

90000

2101

Marcus

Rivera

65.00

10

17

PTE

111

2102

Hector

Chen

75.00

25

17

PTE

45

45

Rajesh

Vishwan

90000

hourly_rat
e

dpt_id

epe_type

epe_i
d

10

FTE

111

10

FTE

25

Copyright 2010, Oracle. All rights reserved.

agy_id

FTE

11

Subtype Mapping

Tell Me / Show Me
When Do You Choose the Single-Table/Supertype
Implementation?
The single-table implementation is a common and flexible
implementation. It is the one you are likely to consider first
and is especially appropriate where:

Most of the attributes are at the supertype level.


Most of the relationships are at the supertype level.
Business rules are globally the same for the subtypes.

Copyright 2010, Oracle. All rights reserved.

12

Subtype Mapping

Tell Me / Show Me
Subtype Implementation: Two Table
This is also called "two-table implementation." You create a
table for each of the subtypes. So, in reality, you could have
more than two tables, if you had more than two subtypes.
Rules
1. Tables: One table per first-level subtype.
2. Columns: Each table gets a column for all attributes of
the supertype with the original optionality.
3. Each table also gets a column for each attribute
belonging to the subtype, also with the original
optionality.

Copyright 2010, Oracle. All rights reserved.

13

Subtype Mapping

Tell Me/ Show Me


Subtype Implementation: Two Table (continued)
Rules
4. Identifiers: The primary UID at the supertype level creates a
primary key for each table. Secondary UIDs of the supertype
become unique keys in each table.
5. Relationships: All tables get a foreign key for a relationship at
the supertype level, with the original optionality. For
relationships at the subtype levels, the foreign key is
implemented in the table it is mapped to. Original optionality is
retained.

Copyright 2010, Oracle. All rights reserved.

14

Subtype Mapping

Tell Me / Show Me
Supertype Implementation: Single Table (continued)
CLOTHING
# id
* material
SHIRT
* sleeve length
* neck size
o collar style
SHOE
* size
* buckle style
o heel height

produced by
the producer of

MANUFACTURER
# id

altered by
the alterer of

repaired by
the repairer of

TAILOR
# id

COBBLER
# id

SHIRTS (SHT)

SHOES (SHE)

Key
Type

Optionality

Column
Name

Key
Type

Optionality

Column
Name

pk

id

pk

id

material

material

sleeve_length

size

neck_size

buckle_style

collar_style

heel_height

fk1

tlr_id

fk1

clr_id

fk2

mnv_id

fk2

mnv_id

refers to manufacturers

refers to tailors refers to cobblers

Copyright 2010, Oracle. All rights reserved.

refers to manufacturers

15

Subtype Mapping

Tell Me / Show Me
Subtype Implementation: Two Table (continued)
In the example, a separate table would be created for SHIRTS and
SHOES.
Sample Data for SHIRTS
id

material

sleeve_length

neck_size

collar_style

mnr_id

tlr_id

10

linen

33

16

button down

65

14

11

wool

32

15.5

nehru

65

22

14

cotton

33

15.5

60

22

Sample Data for SHOES


id

material

size

buckle_style

heel_height

mnr_id

clr_id

leather

7.5

monkstrap

1.5

75

44

canvas

velcro

70

44

Copyright 2010, Oracle. All rights reserved.

16

Subtype Mapping

Tell Me / Show Me
When to Consider Subtype Implementation
Subtype implementation may be appropriate when:

Subtypes have very little in common. There are few attributes


at the supertype level and several at the subtype level.
Most of the relationships are at the subtype level.
Business rules and functionality are quite different between
subtypes.
How tables are used is different -- for example, one table is
being queried while the other is being updated.

Copyright 2010, Oracle. All rights reserved.

17

Subtype Mapping

Tell Me / Show Me
Modeling the Supertype as an Arc
A supertype entity and its subtypes can be modeled as an arc
relationship. Here again is the ERD with the supertype and
subtypes.
CLOTHING
# id
* material

produced by
the producer of

SHIRT
* sleeve length
* neck size
o collar style
SHOE
* size
* buckle style
o heel height

MANUFACTURER
# id

TAILOR
# id

altered by
the alterer of

COBBLER
# id

repaired by
the repairer of

Copyright 2010, Oracle. All rights reserved.

18

Subtype Mapping

Tell Me / Show Me
Model An Arc
Illustrated
In this ERD, we
have redrawn the
CLOTHING
supertype and its
subtypes of SHIRT
and SHOE as
standalone entities
with each one
having mandataory
1:1 relationships
with the supertype.
The relationships
are in an arc.

MANUFACTURER
# id
CLOTHING
# id
* material

produced by
the producer of

a supertype
of
SHIRT
a
subtype
of

* sleeve length
* neck size
o collar style

altered by
the alterer
of

TAILOR
# id

a supertype
of

SHOE
* size
* buckle style
a
subtype o heel height
of

Copyright 2010, Oracle. All rights reserved.

repaired by
the
repairer
of

COBBLER
# id

19

Subtype Mapping

Tell Me / Show Me
Supertype and Subtype (Arc) Implementation
This choice produces one table for every entity. The
supertype table has a foreign key for each subtype table.
These foreign keys represent exclusive relationships. They
are optional because only one of them can have a value for
each row in the table.
Rules
1. Tables: As many tables are created as there are
subtypes, as well as one for the supertype.
2. Columns: Each table gets a column for all attributes of the
entity it is based on, with the original optionality.

Copyright 2010, Oracle. All rights reserved.

20

Subtype Mapping

Tell Me/ Show Me


Supertype and Subtype (Arc) Implementation (continued)
3. Identifiers: The primary UID of the supertype level creates
a primary key for each of the tables. All other unique
identifiers become unique keys in their corresponding
tables.
4. Relationships: All tables get a foreign key for a relevant
relationship at the entity level, with the original optionality.
5. Integrity constraints: Two additional columns are created
in the table based on the supertype. They are foreign-key
columns referring to the tables that implement the
subtypes. The columns are optional because the foreign
keys are in an arc. An additional check constraint is
needed to implement the arc. The foreign-key columns
are also unique keys because they implement a
mandatory 1:1 relationship.
Copyright 2010, Oracle. All rights reserved.

21

Subtype Mapping

Tell Me / Show Me
Supertype and Subtype (Arc) Implementation (continued)
SHIRTS (SHT)
Key Type

Optionality

Column Name

pk

id

sleeve_length

neck_size

collar_style

tlr_id

CLOTHING (CTG)
Key Type

Optionality

Column Name

pk

id

material

fk1, uk1

sht_id

refers to shirts

fk2, uk2

she_id

refers to shoes

fk3

mnr_id

fk1

refers to tailors

refers to
manufacturers

SHOES (SHE)
Key Type

Optionality

Column Name

pk

id

size

buckle_style

heel_height

clr_id

fk1

Copyright 2010, Oracle. All rights reserved.

refers to
cobblers

22

Subtype Mapping

Tell Me / Show Me
When to Consider Both a Supertype and Subtype (Arc)
Implementation
This implementation is rarely used, but it could be appropriate
when:
Subtypes have very little in common and each table
represents information that can be used independently. For
example, when the CLOTHING table gives all global
information, and both SHOES and SHIRTS give specific
information, and the combination of global and specific
information is hardly ever needed.
Business rules and functionality are quite different between
all types.
How tables are used is different.

Copyright 2010, Oracle. All rights reserved.

23

Subtype Mapping

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Supertype implementations
Subtype implementations
Arc implementations

Copyright 2010, Oracle. All rights reserved.

24

Subtype Mapping

Summary
Objectives Summarized
In this lesson, you have learned to:
State and apply the table, column, identifiers, relationship,
and integrity constraint rules for mapping supertype
implementations
State and apply the table, column, identifiers, relationship,
and integrity constraint rules for mapping subtype
implementations
State and apply the table, column, identifiers, relationship,
and integrity constraint rules for mapping supertype and
subtype arc implementations

Copyright 2010, Oracle. All rights reserved.

25

Subtype Mapping

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

26

Oracle Academy
Database Design
Instructor Resource Guide
INSTRUCTOR NOTES
SECTION 11 Introduction to Relational Database Concepts Lesson
Slide 1: Introduction to Relational Database Concepts
Lesson Preparation
This lesson talks about relational databases, primary keys, foreign keys, and data
integrity. This will help with the conceptual to physical mapping later in this section, and
with the transition to SQL in the upcoming sections. Encourage the students to realize
that they are learning a new set of terminology. An entity is not a table, and an attribute is
not a column. We will be transforming (exchanging) one set of objects (ER conceptual
modeling constructs) into another (data design physical model constructs).
What to Watch For
If anyone asks, the word relation is an abstract mathematical term used in set theory. A
mathematical relation has the same logical properties as a table in a database. This is the
origin of the term relational database, i.e. a database consisting of a set of relations
(i.e., tables).
Connections
Remind students that they have seen integrity rules before. These are the business rules
that sometimes cannot be represented in the conceptual model and therefore must be
documented. This is the reason for the documentation to make sure that the
programmers write extra code to enforce these rules in the database!
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Tell Me / Show Me A relational database is a database
Relational database: Collections of objects or relations, set of operators to act on those
relations, and data integrity for accuracy and consistency.
Explain that each row of data describes an employee. Each column is an attribute of that
employee. If we wanted to find out the last name and department number of employee
number 210, we would need to access the third row in the table, and then find the values
for fname and dept_no for that row. But how do we find the correct row in the first place?
Would we have to go through the whole table and look at every row? Answer: No.
(Move on to next page.)

Oracle Academy

1
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 5: Tell Me / Show Me Structured query language (SQL)
Ask students if they understand the SQL code just by reading it. They should have some
ideas because of its English-like syntax.
Slide 6: Tell Me / Show Me Employees (table)
No instructor notes for this slide
Slide 7: Tell Me / Show Me To find all the employees in department
Explain that * after SELECT means we want all the columns in the table.
Slide 8: Tell Me / Show Me Employees (table)
SQL allows us to access the whole table or just parts of the table, depending on what
comes after SELECT and what is specified in the WHERE clause.
Slide 9: Tell Me / Show Me Primary Key (table)
Primary key: A constraint which ensures that the column contains no null values and
uniquely identifies each row of the table.
Point out that in ACCOUNTS, BANK_NO is not unique and ACCT_NO is not unique.
However, the combination of BANK_NO and ACCT_NO is unique.
Slide 10: Tell Me / Show Me Primary Key (table)
Ask students to point out the rows in each table that violate the rule that no part of the
primary key can be null. Answer: Second row in EMPLOYEES, second row in
ACCOUNTS. These rows violate entity integrity.
Slide 11: Tell Me / Show Me A table can have more than one column
Candidate key: More than one column or combination of columns that could serve as
the tables primary key.
Ask students what makes EMPLOYEE_ID and PAYROLL_ID good candidates for the
primary key? Answer: They are both unique and not null.
Slide 12: Tell Me / Show Me Select one candidate key to be
Unique key: An integrity constraint that requires every value in a column or set of
columns be unique.
Ask students why having alternate or unique keys can be useful? Answer: Its another
way to locate a record. If you forget your employee ID, but know your payroll ID (or
have a payroll stub with the ID on it), then you can still access your employee record.

Oracle Academy

2
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 13: Tell Me / Show Me Foreign Key
Foreign key: A column or set of columns that refers to a primary key in the same table or
another table.
Point out that if the foreign key (DEPARTMENT_ID) in EMPLOYEES has a value of
10, then there needs to be a row in DEPARTMENTS with a DEPARTMENT_ID of 10.
Otherwise, it is a violation of referential integrity. You can also explain this in business
terms, by saying that an employee cant belong to a department that doesnt exist.
Slide 14: Tell Me / Show Me if a foreign key is a part of a primary
Point out that in the example, SHELF_NO is part of the primary key of BOOKS. It is
also a foreign key to SHELVES. Since it is part of the PK of BOOKS, it cannot be null.
Slide 15: Tell Me / Show Me Column Integrity
Row: An entry in a table, consisting of values for each appropriate column.
Column: An implementation of an attribute or relationship in a table.
Explain to students that the datatype for the columns BANK_NO, ACCT_NO, and
BALANCE is numeric. The number in parentheses indicates how big the numeric value
can be. A datatype of date means the value must be a valid date. Not null in the
Optionality column means that the column is mandatory. Which rows in the table violate
column integrity? Answer: Second and fourth rows
Slide 16: Tell Me / Show Me Summary of Data-Integrity Rules
No instructor notes for this slide
Slide 17: Tell Me / Show Me (table)
The first three shown here are a summary of the data-integrity rules weve covered. The
last one (an example of user-defined integrity) has not been covered yet, but students
should understand its importance by now.
Slide 18: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 19: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 21: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

3
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 11 Basic Mapping: The Transformation Process Lesson
Slide 1: Basic Mapping: The Transformation Process
What to Watch For
Students may not see a great difference between the conceptual model and the relational
design at this point. They may ask: why not create table definitions from the start?
Explain that simple entities (like the ones they will see in this lesson) are very similar to
relational tables. However, once we get to foreign keys, arcs, and subtypes, there will be
differences.
Also, remind them that when they create a conceptual model, they are focused on the
business and its rules. When they create a database design, the focus will be on database
issues of storage, speed of transactions, security, etc. For example, in a Data Warehouse,
the physical model is often deliberately de-normalized to give faster performance.
Although these are important issues, they should not be considered before or above the
business requirements. Data modeling pays attention to the business requirements,
regardless of implementation. You may have the fastest and most secure database in the
world, but if it doesnt meet your business requirements, its not going to be of much use.
Connections
In earlier lessons students have modeled a number of business scenarios. Tell students to
imagine that the client has approved their model and now wants a system built based on
the model, using a relational database. Transforming that model into a database design
would be the next phase.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
Stress that in this and the next two lessons we are NOT building the house (or creating
the database). We are transforming the terminology we have used to build our
conceptual model into the equivalent relational database terminology, following naming
conventions and restrictions.
Slide 4: Tell Me / Show Me Review of Relational Tables
This and the next few slides are a review of the concepts covered previously.
Slide 5: Tell Me / Show Me Review of Relational Tables (continued)
No instructor notes for this slide
Slide 6: Tell Me / Show Me Review of Relational Tables (continued)
No instructor notes for this slide

Oracle Academy

4
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 7: Tell Me / Show Me Review of Relational Tables (continued)
Remind students that unique keys can be null, unlike primary keys.
Slide 8: Tell Me / Show Me Review of Relational Tables (continued)
No instructor notes for this slide
Slide 9: Tell Me / Show Me Review of Relational Tables (continued)
No instructor notes for this slide
Slide 10: Tell Me / Show Me The conceptual model is transformed
Transform: To change the elements of an ERD (entities, attributes, relationships) into
database elements (tables, attributes, foreign keys).
Differentiate between the EMPLOYEE entity in the ERD (conceptual model) and the
diagram of the EMPLOYEES table, which represents the definition of the table in the
relational model (physical implementation). The notations in the table diagram will be
explained later in this lesson.
Slide 11: Tell Me / Show Me Terminology Mapping
Map: To associate the elements of an ERD (entities, attributes, relationships) with
database elements (tables, attributes, foreign keys).
Explain that analysis and design are phases of the system life cycle (to be discussed more
later). When designing a system, analysis precedes design. Data modeling is done in the
analysis phase. When you are satisfied that you have captured the business requirements
in the data model, you move on to the design phase, where the ERD is mapped to a
physical implementation.
Slide 12: Tell Me / Show Me Terminology Mapping
Stress again that in these simple examples there is a one-to-one mapping between
conceptual and physical terminology (for example one entity becomes one table) but that
this will not always be true in more complex models.
Slide 13: Tell Me / Show Me Table Diagram Notations
Unlike the mandatory table name, a short name is an optional convenience.
Slide 14: Tell Me / Show Me Table Diagram Notations (continued)
No instructor notes for this slide
Slide 15: Tell Me / Show Me Naming Conventions for Tables and Columns
Stress that these are conventions, not rules. However, one reason for using a plural table
name is to avoid possible errors later when the table is created. For example, the Oracle
database will not allow the creation of a table named ORDER, because ORDER is a
reserved word n SQL (SELECT .... ORDER BY ...).
Oracle Academy

5
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 16: Tell Me / Show Me Naming Conventions for Tables and Columns (continued)
Stress that these are conventions, not rules. We replace spaces by underscores in column
names because the Oracle database will not allow spaces (and hyphens etc.) within a
column name.
Slide 17: Tell Me / Show Me Naming Conventions: Short Names
In this and the next slide, stress that short names are NOT mandatory, simply useful. The
suggested rules are one of several possible conventions for determining short names.
Do not spend too much time on them.
Slide 18: Tell Me / Show Me Naming Conventions: Short Names (continued)
These rules do not guarantee uniqueness, but experience has proved that duplicated
names are relatively rare. In the case of identical short names, just add a number to the
one that is used less. Example: CTR and CTR1.
Slide 19: Tell Me / Show Me Naming Conventions: Short Names (continued)
These rules do not guarantee uniqueness, but experience has proved that duplicated
names are relatively rare. In the case of identical short names, just add a number to the
one that is used less. Example: CTR and CTR1.
Slide 20: Tell Me / Show Me Naming Restrictions with Oracle
Note that Oracle table and column names can contain underscores but not hyphens. For
example, SALES_ORDERS is a valid table name but SALES-ORDERS is not. Explain
that all database systems make recommendations on naming objects (such as tables). If
they do not use an Oracle database, they should still decide on a naming convention and
make sure it is compatible with the database system that they have chosen.
Slide 21: Tell Me / Show Me Naming Restrictions with Oracle (continued)
You may want to show the students how to use Technet where the lists of reserved words
in Oracle 10g can be found. This site requires you to sign up, but it is free. It's a valuable
source of technical information on all Oracle products. Technet is currently located at
www.oracle.com/technology, but this could change in future. A safer bet is to go to
www.oracle.com and look for links to Oracle Technology Network.
Slide 22: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 23: Summary In this lesson you have learned to:
No instructor notes for this slide

Oracle Academy

6
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 24: Summary - Practice Guide
No instructor notes for this slide

Oracle Academy

7
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 11 Relationship Mapping Lesson
Slide 1: Relationship Mapping
Connections
Remind them that the barred relationships to ORDER LINE indicate that the UID of
ORDER and FOOD ITEM participate in the UID of ORDER LINE. When the entity is
mapped to table ORDER_LINES, we see that the foreign keys from FOOD_ITEMS and
ORDERS (fim_number and odr_number, respectively) make up the composite primary
key of ORDER_LINES.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Why Learn It? (continued)
No instructor notes for this slide
Slide 5: Tell Me / Show Me Rules for Relationships
No instructor notes for this slide
Slide 6: Tell Me / Show Me (diagrams & tables)
When transforming M:1 relationships, it may be helpful to visualize the crows foot
pulling the UID of the entity on the one side into the entity on the other side (the
crows feet side).
Point out that the ER diagram captures the relationships between entities, expressed in
business terms. When the conceptual model is transformed, the relationships become
foreign-key columns, but the relationship name itself is not carried over. The database
design will be the basis for the system, but starting with a conceptual model ensures that
the tables, columns, and constraints created in the database are relevant to the business
and fulfill its requirements.
A database contains objects such as tables, columns, and constraints. A data modeler sees
how these objects are related from a business perspective.
In the example, dpt_id is mandatory, and epe_id is optional. Give the business example
so that students understand why the epe_id is optional. Does the president of a company
have a manager?
Since epe_id implements the recursive relationship in EMPLOYEE, it is probably better
renamed to mgr_id. Decisions like this can be made at this stage of mapping.

Oracle Academy

8
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 7: Tell Me / Show Me Mapping of Mandatory Relationship at the One Side
No instructor notes for this slide
Slide 8: Tell Me / Show Me (diagrams & tables)
No instructor notes for this slide
Slide 9: Tell Me / Show Me Mapping of Nontransferable Relationships
Nontransferable relationship: information that cannot be updated.
Slide 10: Tell Me / Show Me (diagrams & tables)
In the example, a paycheck may not be transferred to another employee. This means that
the epe_id, which is the foreign-key column in the table PAYCHECKS, cannot be
updated.
Slide 11: Tell Me / Show Me Mapping of Barred Relationships
No instructor notes for this slide
Slide 12: Tell Me / Show Me (diagrams & tables)
Help students visualize the data in ACCOUNTS. The act_nbr alone would not be unique
within the table, but the combination of act_nbr and bak_nbr would be.
Slide 13: Tell Me / Show Me Cascade Barred Relationships
Cascade barred relationships: A series of relationships implying that the unique
identifier of each entity in the chain is carried down to the entity on the next level.
The UIDs and resulting primary keys are highlighted in different colors to help you trace
a UID through the hierarchy.
Slide 14: Tell Me / Show Me (diagrams & tables)
The UIDs and resulting primary keys are highlighted in different colors to help you trace
a UID through the hierarchy.
The primary key of FLOORS now becomes a composite of flr_nbr and bldg_id. The
primary key of SUITES is a composite of sue_nbr, flr_nbr, and flr_bldg_id. Point out that
the composite is one primary key (a table is only allowed to have one PK).
In this case, it is also one foreign key for each table, even if that key is a composite of
multiple columns. The foreign key in SUITES is the combination of flr_nbr and
flr_bldg_id. The foreign key in ROOMs is a combination of sue_nbr, sue_flr_nbr, and
sue_bdg_id.

Oracle Academy

9
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 15: Tell Me / Show Me Sample data for each table illustrate the
Ask students: What is the primary key of ROOMS?
Answer: The combination of rom_nbr, sue_nbr, sue_flr_nbr, and sue_bdg_id.
Verify that the combination of all four is what makes a row unique. Point out that any
three columns alone or in combination does not make a unique value.
Trace the id all the way from BUILDINGS (id) to FLOORS (bdg_id) to SUITES
(flg_bdg_id) to ROOMS (sue_bdg_id).
Slide 16: Tell Me / Show Me Mapping M:M Relationships
Intersection entity: The product of the resolution of a many to many relationship.
Note the subscript notation on each foreign key (fk1 and fk2). This is meant to show that
each foreign-key column references the primary key of a different table. This differs from
previous examples where the foreign-key column (or columns) references the primary
key of a single table.
Slide 17: Tell Me / Show Me (diagrams & tables)
Note the subscript notation on each foreign key (fk1 and fk2). This is meant to show that
each foreign-key column references the primary key of a different table. This differs from
previous examples where the foreign-key column (or columns) references the primary
key of a single table.
Slide 18: Tell Me / Show Me Mapping 1:1 Relationships
Clarify the necessity for a unique key on bcp_code if necessary. Remind them of the
relationship in the conceptual model: Each bottle cap may be the sealer for one and only
one soda bottle. If you had a bottle cap with code AB55, that would be unique in the
SODA_BOTTLES table, because it can occur only in one instance or one row of the
table.
Slide 19: Tell Me / Show Me (diagrams & tables)
Clarify the necessity for a unique key on bcp_code if necessary. Remind them of the
relationship in the conceptual model: Each bottle cap may be the sealer for one and only
one soda bottle. If you had a bottle cap with code AB55, that would be unique in the
SODA_BOTTLES table, because it can occur only in one instance or one row of the
table.

Oracle Academy

10
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 20: Tell Me / Show Me Mapping 1:1 Relationships (Optional or)
Mandatory 1:1 relationships are rare. In most cases, this will be modeled as a single table,
without a need for a 1:1 relationship. However, if you need to clarify the limitation of 1:1
mandatory at both ends, you can revisit the earlier slide on m:1 mandatory on the one
end in this lesson.
Slide 21: Tell Me / Show Me (diagrams & tables)
No instructor notes for this slide
Slide 22: Tell Me / Show Me Mapping Arcs
Point out that pse_id and phe_id in the EVENTS table are optional, but the relationships
in the arc are mandatory (each EVENT must be held at one VENUE). A check constraint
will enforce this mandatory relationship.
Slide 23: Tell Me / Show Me (diagrams & tables)
No instructor notes for this slide
Slide 24: Tell Me / Show Me Mapping Arcs (continued)
You may need to explain the concept of a check constraint, as opposed to additional
programming that is needed to enforce mandatory relationships on the one end (as in
the previously discussed M:1 or 1:1). A check constraint is programming code that can be
stored in the database. It can enforce simple rules that apply to a single row in the table
(such as comparing values or ensuring that they are null or not null). This is the case with
the arc.
In the case of a mandatory one end of a M:1 or 1:1 relationship, we have to check that if a
row is entered in one table (the master), a row must also be entered in another table (the
child, or detail). A check constraint cannot span two tables or different rows in the same
table. It cannot prevent insert, update, or delete operations. This is why additional
programming (instead of a check constraint) is necessary.
Slide 25: Tell Me / Show Me (diagrams & tables)
No instructor notes for this slide
Slide 26: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 27: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 28: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

11
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 11 Subtype Mapping Lesson
Slide 1: Subtype Mapping
Lesson Preparation
You may want to review supertypes and subtypes briefly. Use the DJ and Global Foods
ERDs as examples.
What to Watch For
Students may get bogged down in the arc implementation of a supertype. The best way to
understand it is to redraw the data model using an arc instead of a supertype. Then
transform the model as an arc. The tricky part is that the relationships in the arc are 1:1
instead of M:1, which is usually seen in an arc.
1:1 relationships are not modeled that often; usually the data modeler will use one entity
instead of two. For this reason, modeling supertypes as arcs is not that common either.
Arcs are best used to express exclusive relationships, not a type of condition.
Let students know that most of the time, the single-table implementation is used.
Connections
Section 12, Lesson 3, also discusses mapping 1:1 relationships, as well as arcs. Students
may need to review this to understand why a 1:1 relationship results in a unique key on
the mandatory side.
For a review of supertype modeling, refer to Section 4, Lesson 3.
For a review of arcs and exclusive relationship modeling, refer to Section 7, Lesson 3.
Slide 2: What Will I Learn?
Tell students that there are three ways to implement supertypes in the database. All three
will be discussed in this lesson.
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Tell Me / Show Me Supertype Implementation: Single Table
Supertype: A means of classifying an entity that has subtypes.
Slide 5: Tell Me / Show Me Supertype Implementation: Single Table (continued)
No instructor notes for this slide

Oracle Academy

12
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 6: Tell Me / Show Me (diagrams & tables)
Point out that salary and hourly_rate are both optional, even if the ERD has them as
mandatory. dpt_id can remain mandatory, because it comes from the relationship to the
supertype EMPLOYEE. agy_id comes from a relationship to the subtype and has to
become optional.
epe_type is the discriminator column. It can have values of FTE or PTE.
Notice that mgr_id represents the recursive relationship for EMPLOYEE. It is a foreign
key column and would normally be named epe_id, after the parent table. However, it
makes sense to rename it at this stage, to make it easier to understand.
Slide 7: Tell Me / Show Me Supertype Implementation: Single Table (continued)
A check constraint is necessary to ensure that (epe_type = FTE and salary is not null
and hourly_rate is null and agy_id is null) OR (epe_type PTE and salary is null and
hourly_rate is not null and agy_id is not null).
epe_id is the employee identifier of each employees manager.
A note about the OTHER subtype:
An OTHER subtype is recommended in the conceptual model to ensure that the subtypes
are exhaustive. However, by the time we start the design phase, we should have done
extensive analysis to determine if another subtype is truly needed. If so, then this subtype
must be named, and its attributes specified. If not, then the OTHER subtype is not part of
the transformation process.
Slide 8: Tell Me / Show Me Supertype Implementation: Single Table (continued)
Explain that a check constraint is activated when you insert or update a row in the table.
So, if you tried to update the row for Marcus Rivera by putting a value in the salary
column, the check constraint would prevent you from succeeding. Similarly, if you
wanted to enter a new row for a full-time employee (epe_type = FTE), but tried to enter a
value for agy_id, the check constraint would prevent the insert.
Slide 9: Tell Me / Show Me Supertype Implementation: Single Table (continued)
No instructor notes for this slide
Slide 10: Tell Me / Show Me Supertype Implementation: Single Table (continued)
No instructor notes for this slide
Slide 11: Tell Me / Show Me (diagrams & tables)
Explain that a check constraint is activated when you insert or update a row in the table.
So, if you tried to update the row for Marcus Rivera by putting a value in the salary
column, the check constraint would prevent you from succeeding. Similarly, if you
wanted to enter a new row for a full-time employee (epe_type = FTE), but tried to enter a
value for agy_id, the check constraint would prevent the insert.
Oracle Academy

13
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 12: Tell Me / Show Me When Do You Choose the Single-Table/Supertype
Implementation?
This is the implementation used most often. It is elegant and appropriate for most
situations and should be considered as the first choice.
Usually you would create a view for every subtype, showing only the columns that
belong to that particular subtype. The correct rows are selected using a condition based
on the discriminator column. Example:
CREATE OR REPLACE FULL_TIME_VW AS
Select id, first_name, last_name, salary, dpt_id, epe_id from EMPLOYEES where
epe_type = FTE;
Slide 13: Tell Me / Show Me Subtype Implementation: Two Table
Subtype: Something an entity may be split into based on common attributes and/or
relationships.
Slide 14: Tell Me / Show Me Subtype Implementation: Two Table (continued)
No instructor notes for this slide
Slide 15: Tell Me / Show Me (diagrams & tables)
Point out that the original optionality of the attributes and relationships is carried over to
the columns and foreign keys, so there is no need for a check constraint as there is in the
one-table implementation.
If there were a need to have unique values of the primary key (ID) across both tables,
then additional programming would be necessary.
Slide 16: Tell Me / Show Me Subtype Implementation: Two Table (continued)
Point out that id, material, and mnr_id come from attributes in OR relationships to the
supertype. Therefore, they appear in both tables.
Slide 17: Tell Me / Show Me When to Consider Subtype Implementation
Usually you would create an additional view that represents the supertype, showing all
columns of the supertype and the various subtypes. The view SELECT statement must
use the UNION operator.
Slide 18: Tell Me / Show Me Modeling the Supertype as an Arc
We have previously discussed how supertypes and subtypes can also be drawn as an arc.
We are illustrating this with the example, so that students can better understand the arc
implementation.

Oracle Academy

14
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 19: Tell Me / Show Me In this ERD, we have redrawn the CLOTHING
Discuss why the relationships are 1:1 mandatory and exclusive:
Each SHIRT must be one piece of CLOTHING. Each SHOE must be one piece of
CLOTHING.
Conversely, each piece of CLOTHING must be either a SHOE or a SHIRT but
not both.
Point out that most of the time, the data modeler would choose to model this with a
supertype (previous diagram) because of the 1:1 mandatory nature of the relationships.
Recall that 1:1 mandatory relationships usually indicate that a single entity is needed.
Arcs are more often used when the exclusive relationships are 1:M.
Slide 20: Tell Me / Show Me Supertype and Subtype (Arc) Implementation
Arc: A curved line used to represent an exclusive relationship in an entity-relationship
diagram.
Slide 21: Tell Me / Show Me 3. Identifiers: The primary UID of the
No instructor notes for this slide
Slide 22: Tell Me / Show Me (diagrams & tables)
Point out that it is not necessary to remodel the supertype as an arc (as we did), in order
to choose to do an arc implementation. However, it makes sense to do so for clarity.
If necessary, recall the previous lesson on mapping an arc. You would need a check
constraint on CLOTHING to enforce that (sht_id is not null and she_id is null) OR
(sht_id is null and she_id is not null).
Slide 23: Tell Me / Show Me When to Consider Both a Supertype and Subtype (Arc)
Implementation
Although you would hardly use them, you could consider creating additional views that
represent the supertype and subtypes in full.
Slide 24: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 25: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 26: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

15
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 11 Introduction to Oracle Application Express (OAE) Lesson
Slide 1: Introduction to Oracle Application Express (OAE)
Lesson Preparation
For this lesson, we will perform the Try It/Solve It activity (use OAE) before we explain
what happened in Tell Me/Show Me.
Oracle Application Express User Guide This document will help you become familiar
with how to use Oracle Application Express and each of its components from and end
users perspective. If you would like to learn more about the administrative capabilities or
teacher capabilities of Oracle Application Express, please refer to the Oracle Application
Express Teacher Guide.
To log into Oracle Application Express, go to http://iacademy.oracle.com
Enter your school, username, and password information. This information was given to
you via email from academy_us@oracle.com. If you did not receive this information,
please email: academy_us@oracle.com. You must be a registered and paid DM/SQL
instructor. Students will get their account information from their teacher.
What to Watch For
Students will quickly catch on to Oracle Application Express and creating tables.
Encourage them but set a standard for appropriateness.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 5: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

16
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
PRACTICE SOLUTIONS
SECTION 11 Introduction to Relational Database Concepts Lesson
Vocabulary
Part One: Identify the vocabulary word for each definition below.
A constraint which ensures that the column contains
no null values and uniquely identifies each row of
the table.
A column or set of columns that refers to a primary
key in the same table or another table.
An entry in a table, consisting of values for each
appropriate column
An implementation of an attribute or relationship in
a table
An integrity constraint that requires every value in a
column or set of columns be unique.
Collections of objects or relations, set of operators to
act on those relations, and data integrity for accuracy
and consistency.
More than one column or combination of columns
that could serve as the tables primary key

Primary key

Foreign key
Row
Column
Unique key
Relational database

Candidate key

Part Two: Identify the integrity rules below.


Column-integrity rule
Data-integrity rule

Entity integrity rule


Referential integrity rule
User-defined integrity rule

Oracle Academy

A column must contain only values consistent with


the defined data format of the column
Define the relationally correct state for a database;
they ensure that users can perform only those
operations that leave the database in a correct,
consistent state
A primary key must be unique and no part of the
primary key can be null
A foreign key must match an existing primary key
value (or else be null)
The data stored in a database must comply with the
rules of the database

17
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Try It / Solve It
1. Data Integrity in the DJ Database
Examine the sample data for these tables in the DJs on Demand database. Check for
entity, referential and column integrity. Identify any data-integrity violations. Assume
that all date columns should have a date format and all amount (cost) columns should
have a number format.

Oracle Academy

18
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Solution:
CLIENTS table
Entity integrity: ID for Sarika Patel should not be null.
EVENTS TABLE
Column integrity: Cost for Collins wedding (event id = 17) is not numeric.
Column integrity: Date for Collins rehearsal dinner (event id = 25) is not a valid date
format.
Referential integrity: There is no client 77 in the CLIENTS table (event id = 50).
Referential integrity: There is no theme corresponding to BB in the THEMES table
(event id = 15).

Oracle Academy

19
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 11 Basic Mapping: The Transformation Process Lesson
Vocabulary
Part One: Identify the vocabulary word for each definition below.

Transform
Map

To change the elements of an ERD into database


elements
To associate the elements of an ERD with database
elements

Try It / Solve It
1. Transform the following entities into table definitions, using suitable naming
conventions.

Solution:
Explain that we are not creating tables; we are creating definitions of tables. The
physical implementation of the table will be done in a later lesson using HTML DB.
Check that students have recognized the composite UID in BANK ACCOUNT.
Although we are not too concerned with foreign key relationships at this stage, some
students will recognize that bank id in BANK ACCOUNT is probably a foreign key
to a BANK entity.

Oracle Academy

20
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
2. Match the ERD elements to their corresponding database elements.
Analysis
Attribute (1)
Entity (2)
ER Model (3)
Instance (4)
Primary UID (5)
Relationship (6)
Secondary UID (7)

Design
Column (1)
Foreign key (6)
Physical design (3)
Primary key (5)
Row (4)
Table (2)
Unique key (7)

3. Identify the table diagram notations listed below.


pk
Primary key
fk
Foreign key
uk
Unique key
*
Mandatory
o
Optional
4. Create short names for the terms below based on the naming conventions rules.
Academic major
AMR
Undergraduate
UDE
Class
CLS
5. Identify what is wrong with each of the table names below.
1997classes
Can't start with numbers: must start with a letter

Schedule_of_classes_spring_2003
Name is more than 30 characters long

Financial Aid deadlines!


Name cannot contain spaces or special characters

6. (Optional Practice: Global Fast Foods)


This practice is step 11 in the Global Fast Foods project.

Oracle Academy

21
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 11 Relationship Mapping Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Nontransferable relationship
Cascade barred relationship

Intersection entity

A relationship in a database where the foreign key


column in the database table cannot be updated
A series of relationships implying that the unique
identifier of each entity in the chain is carried down
to the entity on the next level
The product of the resolution of a many to many
relationship.

Try It / Solve It
Relationship Mapping
The following entities were mapped to tables in the previous lesson: SHIFT, REGULAR
MENU, PROMOTIONAL MENU, FREQUENT DINER CARD.
Refer to the completed Global Fast Foods model and map the following entities:
FOOD ITEM
ORDER
ORDER LINE
1. Transform relationships into foreign-key columns.
Use as many rows as necessary in the following table diagram.
Key Type
(pk, uk,
fk)

Oracle Academy

Optionality (* or
o)

Column
Name

22
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide

2. Indicate if a check constraint or additional programming is needed to enforce the


relationship in the database. Under each table diagram, write the conditions that the
check constraint or program has to ensure.
For example:
To enforce exclusive relationships, a check constraint is needed to make sure
that (column A is not null and column B is null) OR (column A is null and
column B is not null).
To enforce a nontransferable relationship, additional programming is needed to
make sure that the <foreign key column> cannot be updated.
Solution:
A check constraint is needed to enforce: either (rmu_code is null and pmu_code is not
null) OR (rmu_code is null and pmu_code is not null).
Additional programming is needed to ensure that stf_id is not updateable. This will
enforce the non-transferability of the relationship between ORDER and STAFF.
Oracle Academy

23
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 11 Subtype Mapping Lesson
Try It / Solve It
1. Transform the PARTNER supertype in the DJ model, using the supertype or singletable implementation.
Solution: After going through the activity, you may want to conduct the following
discussion to check for understanding:
Remind students that they need a discriminator column. What would this
column be named? (Answer: pnr_type.) What are the allowable values for
this column? (Answer: EPR, DJ, MNR.)
Remind students that they need a check constraint. What would it check for?
(Answer: (pnr_type = EPR and expertise is not null and specialty is null and
authorized_expense_limit is null) or (pnr_type = DJ and expertise is null and
specialty is not null and authorized_expense_limit is null) or (pnr_type
=MNR and expertise is null and specialty is null and
authorized_expense_limit is not null).)
What does the foreign-key column pnr_id refer to? (Answer: the PARTNERS
table.)
What relationship was it mapped from? (Answer: the recursive relationship in
PARTNER.)
What does it represent? (Answer: the id of the partners manager.)
2. Transform the STAFF supertype in the Global Fast Foods model, using the subtype or
two-table implementation.
Solution:
Global Fast Foods

Oracle Academy

24
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
After going through the activity, you may want to conduct the following discussion to
check for understanding:
What does the foreign-key column mnr_id refer to? (Answer: the
MANAGERS table.)
What relationship was it mapped from? (Answer: the recursive relationship in
STAFF.)
What does it represent? (Answer: the id of the manager.)
3. Identify the database rules for each part of the database implementations below.
Supertype implementations
Table
Column
Identifiers
Relationship
Integrity constraint rules
Subtype implementations
Table
Column
Identifiers
Relationship
Integrity constraint rules
Arc implementations
Table
Column
Identifiers
Relationship
Integrity constraint rules
Solution:
Supertype implementations
Table: Only one table is created, independent of the number of subtypes.
Column: The single table gets a column for all the attributes of the supertype,
with the original optionality.
Identifiers: Unique identifiers transform into primary and unique keys.
Relationship: Relationships at the supertype level transform as usual.
Relationships at subtype level are implemented as optional foreign-key columns.
Integrity constraint rules: A check constraint is needed to ensure that for each
particular subtype, all columns that come from mandatory attributes are not null.
Oracle Academy

25
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Subtype implementations
Table: One table per first-level subtype.
Column: Each table gets a column for all attributes of the supertype with the
original optionality.
Identifiers: The primary UID at the supertype level creates a primary key for
each table. Secondary UIDs of the supertype become unique keys in each table.
Relationship: All tables get a foreign key for a relationship at the supertype level,
with the original optionality.
Arc implementations
Table: As many tables are created as there are subtypes, as well as one for the
supertype.
Column: Each table gets a column for all attributes of the entity it is based on,
with the original optionality.
Identifiers: The primary UID of the supertype level creates a primary key for
each of the tables. All other unique identifiers become unique keys in their
corresponding tables.
Relationship: All tables get a foreign key for a relevant relationship at the entity
level, with the original optionality.
Integrity constraint rules: Two additional columns are created in the table based
on the supertype. They are foreign-key columns referring to the tables that
implement the subtypes. The columns are optional because the foreign keys are in
an arc. An additional check constraint is needed to implement the arc. The
foreign-key columns are also unique keys because they implement a mandatory
1:1 relationship.

Oracle Academy

26
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 11 Introduction to Oracle Application Express (OAE) Lesson
Try It / Solve It
Creating the MUSIC table
You will be using an application called Oracle Application Express to log on to the
database, create tables, and insert data. Your instructor will walk you through the process
of logging on and using the application.
1. You will be creating a database table called MUSIC. The table data is provided here.
Can you identify the column names? How many rows does the table have? What is
the unique identifier of this table? Can you give an example of an instance of the
MUSIC table?
MUSIC_ID
1
2
3
4
5
6
7
8
9

ARTIST_NAME
BOB MARLEY
BRITNEY SPEARS
NSYNC
SHAGGY
JIMMY CLIFF
KID ROCK
THIRD WORLD
LENNY KRAVITZ
YELLOW MAN

TYPE
REGGAE
POP
POP
REGGAE
REGGAE
RICJ
REGGAE
ROCK
REGGAE

Your instructor will step you through the process of creating the MUSIC table using
Oracle Application Express. You can use the music.sql script that your instructor will
provide or enter the CREATE TABLE statement yourself.
SQL statement:
CREATE TABLE MUSIC
( MUSICID NUMBER(2) NOT NULL,
ARTIST_NAME VARCHAR2(20),
TYPE VARCHAR2(13),
CONSTRAINT MUSIC_PRIMARY_KEY PRIMARY KEY (MUSICID));

Oracle Academy

27
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
After you create your table, you will populate it with data. You can use the music.sql
script that your instructor provides or enter the INSERT statements yourself.
What did we just do? We used SQL to create a table in the database and to insert data
into the table.
Solution:
Review the Oracle Application Express User's Guide. Step through it with students,
making sure each student can log on successfully.
Give each student a copy of the MUSIC table.
Have them answer the questions ABOVE.
Answers: Column names are musicid, artist_name, type. There are nine rows in the
table. The unique identifier is musicid. Any row in the table can be an example of an
instance.
Students can either enter the music-table statements themselves in Oracle Application
Express or use the music.sql script with the statements already written. The CREATE
TABLE statement must be run first and then each INSERT statement entered one at a
time.
Explain that SQL stands for structured query language, and they are going to use SQL
commands to create a table in the database.
a. Give each student a copy of the music.sql file.
b. Walk them through the SQL syntax: CREATE TABLE <table name> is the
SQL command. In the example, the table name is MUSIC. This command
must be followed with a list of columns and their datatype and any constraints.
This list must be enclosed in parentheses. The most common datatypes are
varchar(length), number(length), and date. In the example: MUSICID is the
first column, with datatype NUMBER(2); ARTIST_NAME is the second
column with datatype of varchar(20). NOT NULL specified after a column
name and datatype means that the column is mandatory. In the example:
MUSICID is mandatory. After the list of columns, you can also specify a
constraint for the table, with the word CONSTRAINT. In the example: the
constraint is a primary key on the column MUSICID. Each SQL statement
ends with a semicolon.
c. Log on to HTML DB. Wait until all students have successfully logged on.
d. Step students through the process for entering the CREATE TABLE statement
in the SQL window.
e. If they prefer to run the script, instruct them to use the command @music.sql.
f. HTML DB should return a table created successfully statement. Don't
continue until all students have successfully created the MUSIC table.

Oracle Academy

28
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Explain to students that the INSERT statements must be entered and run one at a
time.
Explain to students that they used Oracle Application Express to log on to the Oracle
database and ran a SQL script (or entered SQL statements) to create a table and enter
data into the database.

Oracle Academy

29
Database Design
Copyright 2011, Oracle. All rights reserved.

Introduction to Oracle Application Express

Copyright 2011, Oracle. All rights reserved.

Oracle Application Express

What Will I Learn?


Objectives
In this lesson, you will learn to:
Log into the Oracle Application Express practice
environment
Create a table using a script in Oracle Application
Express
Enter sample data into the table created
Execute a defined query on the table to validate
successful data insertion

Copyright 2010, Oracle. All rights reserved.

Oracle Application Express

Why Learn It?


Purpose
You have drawn the plans for your dream house and then
transformed it into a physical design for the house. The next
step is to actually build the house. You will need tools to do
this.

Oracle Application Express (OAE) is a tool that will allow you


to build tables in an Oracle database.

Copyright 2010, Oracle. All rights reserved.

Oracle Application Express

Summary
Objectives Summarized
In this lesson, you have learned to:
Log into the Oracle Application Express practice
environment
Create a table using a script in Oracle Application Express
Enter sample data into the table created
Execute a defined query on the table to validate successful
data insertion

Copyright 2010, Oracle. All rights reserved.

Oracle Application Express

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

SQL Introduction: Querying the Database

Copyright 2011, Oracle. All rights reserved.

SQL Introduction: Querying the Database

What Will I Learn?


Objectives
In this lesson, you will learn to:
Apply the rules of SQL to display all columns and a
subset of columns specified by criteria
Add new data with a different value in the type
column
Refine the SQL query to display only those rows that
have data with the new type

Copyright 2010, Oracle. All rights reserved.

SQL Introduction: Querying the Database

Why Learn It?


Purpose
What if every time you got dressed for school, you had to take out
all of your clothes from every dresser and closet in your whole
house? You might be late for school and youd certainly have a lot
to clean up! Accessing data in a database is a similar process if
you dont limit what youre looking for with criteria.

When retrieving information from a database, you will often have to


find a subset of the data, based on specific criteria. Becoming
familiar with SQL will help you get the information you need.

Copyright 2010, Oracle. All rights reserved.

SQL Introduction: Querying the Database

Tell Me / Show Me
DESCRIBE Command
The DESCRIBE command displays the structure of the
table. The syntax is:
DESCRIBE <table name>;

Copyright 2010, Oracle. All rights reserved.

SQL Introduction: Querying the Database

Tell Me / Show Me
Basic SELECT Statement
The SELECT * command returns all the rows in a
table. The syntax is:
SELECT * FROM <table name>;

Copyright 2010, Oracle. All rights reserved.

SQL Introduction: Querying the Database

Tell Me / Show Me
Select Statement With a Condition
To return a subset of the data, modify the SELECT
statement. The syntax is:
SELECT <column name 1, column name 2,
etc.>
FROM <table name>
WHERE <condition>;

Copyright 2010, Oracle. All rights reserved.

SQL Introduction: Querying the Database

Tell Me / Show Me
Inserting Data
Using the INSERT command, you can add a row of data
to the table. The syntax is:
INSERT INTO <table name>
VALUES (value 1, value 2, value 3, etc);

Copyright 2010, Oracle. All rights reserved.

SQL Introduction: Querying the Database

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Modification
Subset
Syntax

Copyright 2010, Oracle. All rights reserved.

SQL Introduction: Querying the Database

Summary
Objectives Summarized
In this lesson, you have learned to:
Apply the rules of SQL to display all columns and a
subset of columns specified by criteria
Add new data with a different value in the type column
Refine the SQL query to display only those rows that
have data with the new type

Copyright 2010, Oracle. All rights reserved.

SQL Introduction: Querying the Database

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

10

Basic Table Modifications

Copyright 2011, Oracle. All rights reserved.

Basic Table Modifications

What Will I Learn?


Objectives
In this lesson, you will learn to:
Add a new column to a table
Use the DELETE and ALTER TABLE commands to
correct mistakes or make revisions to a table

Copyright 2010, Oracle. All rights reserved.

Basic Table Modifications

Why Learn It?


Purpose
What if you were building a house and decided to
change the placement of a window or door? If you
change your mind or make a mistake, there should be
a way to remove or change a feature of the house.
Modifying a table addresses the same need when
building a database. SQL anticipated this need and
has commands to perform these functions.

Copyright 2010, Oracle. All rights reserved.

Basic Table Modifications

Tell Me / Show Me
ALTER TABLE Syntax
To add a new column to a table, use the ALTER
TABLE command. The syntax is:
ALTER TABLE <table name>
ADD (<new_column_name> <data type>);

Copyright 2010, Oracle. All rights reserved.

Basic Table Modifications

Tell Me / Show Me
Drop A Column
To drop a column from a table, use the ALTER TABLE
command. The syntax is:
ALTER TABLE <table name>
DROP COLUMN <column_name>;

Copyright 2010, Oracle. All rights reserved.

Basic Table Modifications

Tell Me / Show Me
Delete a Row
To delete a row from a table, use the DELETE
command. The syntax is:
DELETE from <table name>
WHERE <column_name> = 'some value;

Copyright 2010, Oracle. All rights reserved.

Basic Table Modifications

Summary
Objectives Summarized
In this lesson, you have learned to:
Add a new column to a table
Use the DELETE and ALTER TABLE commands to
correct mistakes or make revisions to a table

Copyright 2010, Oracle. All rights reserved.

Basic Table Modifications

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

System Development Life Cycle

Copyright 2011, Oracle. All rights reserved.

System Development Life Cycle

What Will I Learn?


Objectives
In this lesson, you will learn to:
List and describe the different stages of the systemdevelopment life cycle
Identify the role of data modeling in the systemdevelopment life cycle
Relate the project tasks to the different stages of the
system-development life cycle

Copyright 2010, Oracle. All rights reserved.

System Development Life Cycle

Why Learn It?


Purpose
When you build a house, you draw up the plans before
you start construction. During construction, you lay the
foundation before you start putting up walls. You finish
all the major construction before you start decorating.
The architect, the builder, and the decorator work
accordingly so that they do their jobs at the appropriate
time.

A knowledge of the tasks associated with each stage of


the system-development life cycle will help you plan a
project better and be a productive member of the team.

Copyright 2010, Oracle. All rights reserved.

System Development Life Cycle

Tell Me / Show Me
System Development Life
Cycle
From concept to production,
you can develop a database
by using the systemdevelopment life cycle,
which contains multiple
stages of development. This
top-down, systematic
approach to database
development transforms
business-information
requirements into an
operational database.

D
O
C
U
M
E
N
T
A
T
I
O
N

Copyright 2010, Oracle. All rights reserved.

Strategy and Analysis

Design

Build

Transition

Production

System Development Life Cycle

Tell Me / Show Me
Strategy and Analysis
Study and analyze the
business requirements.
Interview users and
managers to identify the
information requirements.
Incorporate the enterprise
and application mission
statements as well as any
future system
specifications.

EMPLOYEE
# id
* first name
* last name
* date of birth

belong to

Copyright 2010, Oracle. All rights reserved.

DEPARTMENT
# id
* description
o budget

composed of

System Development Life Cycle

Tell Me / Show Me
Strategy and Analysis
(continued)
Build conceptual models of
the system. Transfer the
business narrative into a
graphical representation of
business-information
needs and rules. Confirm
and refine the model with
the analysts and experts.

EMPLOYEE
# id
* first name
* last name
* date of birth

belong to

Copyright 2010, Oracle. All rights reserved.

DEPARTMENT
# id
* description
o budget

composed of

System Development Life Cycle

Tell Me / Show Me
Design
Transform the model
developed in the strategy
and analysis phase. Map
entities to tables, attributes
to columns, relationships
to foreign keys, and
business rules to
constraints.

EMPLOYEES (EPE)
pk

fk

id

first_name

last_name

date_of_birth

dpt_code

refers to

DEPARTMENTS (DPT)
pk

Copyright 2010, Oracle. All rights reserved.

id

description

budget

System Development Life Cycle

Tell Me / Show Me
Build
Write and execute the commands to
create the tables and supporting objects
for the database.
Populate the tables with data.
Develop user documentation, help text,
and operations manuals to support the
use and operation of the system.

Copyright 2010, Oracle. All rights reserved.

System Development Life Cycle

Tell Me / Show Me
Transition
Conduct user-acceptance testing.
Convert existing data and parallel
operations. Make any modifications
required.
Production
Roll out the system to the users.
Operate the production system. Monitor
its performance and enhance and refine
the system.

Copyright 2010, Oracle. All rights reserved.

System Development Life Cycle

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Parallel operations
Populate
System development life cycle
User- acceptance testing

Copyright 2010, Oracle. All rights reserved.

10

System Development Life Cycle

Summary
Objectives Summarized
In this lesson, you have learned to:
List and describe the different stages of the systemdevelopment life cycle
Identify the role of data modeling in the systemdevelopment life cycle
Relate the project tasks to the different stages of the
system-development life cycle

Copyright 2010, Oracle. All rights reserved.

11

System Development Life Cycle

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

12

Oracle Academy
Database Design
Instructor Resource Guide
INSTRUCTOR NOTES
SECTION 12 SQL Introduction: Querying the Database Lesson
Slide 1: SQL Introduction: Querying the Database
Lesson Preparation
Have each student access the link to the basic SQL commands.
What to Watch For
Students will quickly learn the basic SQL commands and want to do more at this point.
Explain to them that getting data from more than one table and other operations will have
to wait a few weeks.
Connections
Retrieving data is like interviewing your clients. You are trying to get specific
information from that giant database of a client! Recall the animal-shelter activity when
students interviewed the director. Students had to understand what the director knew
about the functions of the animal shelter so that they could properly meet the directors
needs. Ask them what they would do now if the director wanted a report of all animals
currently in the shelter?
Possible responses: Use SQL to get it out of a database. Or build the database with
create tables, enter data, and then extract data using a SELECT * FROM Animals.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Tell Me / Show Me The DESCRIBE command displays the structure
Syntax: The rules governing the formation of statements in a programming language.
Write the DESCRIBE music syntax on the board. Ask students to enter the SQL
command. Discuss what the statement means and what it returns.
Slide 5: Tell Me / Show Me The SELECT * command returns all the rows
Write the SELECT * FROM music syntax on the board. Ask students to enter the SQL
command. Discuss what the statement means and what it returns.

Oracle Academy

1
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 6: Tell Me / Show Me To return a subset of the data, modify the SELECT
Explain that the <condition> often takes the form of column name + operator (=, >, <, IS
NULL, IS NOT NULL, etc.).
Slide 7: Tell Me / Show Me Using the INSERT command, you can add a row
Ask what would happen if you tried to insert a row with values (9, ERIC CLAPTON,
ROCK).
Answer: You would get an error because there is already a row with musicid = 9.
Musicid is the primary key of the table and must be unique.
Slide 8: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 9: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 10: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

2
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 12 Basic Table Modifications Lesson
Slide 1: Basic Table Modifications
Connections
Retrieving data is like interviewing your clients. You are trying to get specific
information from that giant database of a client! Recall the animal-shelter activity when
students interviewed the director. Students had to understand what the director knew
about the functions of the animal shelter so that they could properly meet the directors
needs. Ask them what they would do now if the director wanted a report of all animals
currently in the shelter?
Possible responses: Use SQL to get it out of a database. Or build the database with
create tables, enter data, and then extract data using a SELECT * FROM Animals.
Slide 2: What Will I Learn?
Add Column: Mention that this type of change to a table is different from adding or
removing data. Youre changing the structure. This is called DDL (data definition
language youll learn more about this in SQL). Its good to mention this at this point so
that, when students hear it later, it will be familiar.
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Tell Me / Show Me To add a new column to a table, use
You may want to demonstrate this on your computer if you can share your screen with
the students. Add a column to the MUSIC table using the ALTER TABLE command,
but misspell the column (e.g., COUNTRI instead of COUNTRY).
Slide 5: Tell Me / Show Me To drop a column from a table, use
Demonstrate this by dropping the misspelled column. Have students suggest how to add
the column again. Ask for the syntax.
Slide 6: Tell Me / Show Me To delete a row from a table, use the
Point out that numbers do not require quotes around them (example: 10), but text does
(example: ERIC CLAPTON).
Slide 7: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 8: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

3
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 12 Project Overview and Getting Started Lesson
Slide 1: Project Overview and Getting Started
Lesson Preparation
Up to this point, students have learned data-modeling concepts and tested their
understanding by solving problems and answering questions at the end of each lesson.
Interspersed with the data-modeling content have been lessons on foundation skills or
professional skills needed to succeed in today's competitive marketplace (What Is a
Consultant? Overcoming the Fear Factor, Leaders in IT, What About Me?, The Changing
Nature of Work). Throughout the course, students have also demonstrated basic
presentation skills (IOUG Case Presentation, Animal Shelter Activity).
The final presentation project challenges students to put it all together.
Using a relevant real-world example, the intent of the project is to apply data-modeling
concepts as they are learned and to teach presentation skills essential for business.
Working in groups of two or three, students will choose a scenario based on a real-world
business example where a database would be needed. Acting as consultants to this
business, students will define the need for the database, identify the components, create
an ERD, write documentation, and present their database design. Several project ideas are
provided, but students can elect to explore a project of its own choosing. Each group will
present its project results as a culminating activity for this course.
Review the list of project ideas. It may be difficult for some students to identify a specific
project. Your task is to help students identify an area of interest: I know I would not like
to, I am not interested in..., I have always been interested in..., etc. Give students the
project list and ask them to read through the suggested topics. Have them place a +
next to their top five choices and a - next to five topics they are not interested in. At
this point, encourage students to choose what they find interesting and not what their best
friend likes.
Organize students into groups of two or three.
Suggestion about forming groups: Don't reveal how you will assign the groups. After
students have made their five highest and lowest choices, ask one student to verbally
announce their highest choices. See if someone else also had one of these choices on
his/her list. These two students form a team and compare their other choices. They then
try to find another student who also shares their choice these will become the groups.
You also can choose to have them draw numbers so that it is randomized.
Give student groups time to refine or design their own topic. It is important that students
choose a topic they are interested in and are committed to completing. Let them know
that changing their project is not an option once started.
Alternatively, you can choose a specific project and assign it to the class. You may want
to have them work with a project whose solution you are familiar with.
Oracle Academy

4
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
Explain that presentation skills are essential to becoming a productive employee.
Presentation skills build the foundation for success as a future IT professional. Research
shows that 83% of the information we take in is by sight; only 17% is from taste, touch,
smell, or hearing. Data modeling is a process that relies on presentation skills to refine
the information requirements of the client as well as to demonstrate a completed database
design for final approval.
Slide 4: Why Learn It? (continued)
No instructor notes for this slide
Slide 5: Tell Me / Show Me You will now have the opportunity
No instructor notes for this slide
Slide 6: Tell Me / Show Me Acting as consultants to this business, you will
Explain that the animation presents a slice of the process they will be going through in
the next seven days. Their work will be more detailed, and they will take more time than
the animation, but this will give them a preview of what theyll be doing
Slide 7: Tell Me / Show Me Presentation Project Ideas (purpose)
Explain the purpose of the project to the students. Have them review the list of project
ideas. If they want to come up with their own topic, they are free to do so, provided that
they let you know, and that you approve it for their project.
Slide 8: Tell Me / Show Me Presentation Project Ideas (begin)
No instructor notes for this slide
Slide 9: Tell Me / Show Me Presentation Project Ideas (starting points)
No instructor notes for this slide
Slide 10: Tell Me / Show Me Presentation Project Ideas Environmental
No instructor notes for this slide
Slide 11: Tell Me / Show Me Presentation Project Ideas Environment (continued)
No instructor notes for this slide
Slide 12: Tell Me / Show Me Presentation Project Ideas Historical
No instructor notes for this slide
Slide 13: Tell Me / Show Me Presentation Project Ideas Historical (continued)
No instructor notes for this slide
Oracle Academy

5
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 14: Tell Me / Show Me Presentation Project Ideas Business
No instructor notes for this slide
Slide 15: Tell Me / Show Me Presentation Project Ideas Science
No instructor notes for this slide
Slide 16: Tell Me / Show Me Presentation Project Ideas Humanities
No instructor notes for this slide
Slide 17: Tell Me / Show Me Written Documentation
Print and hand out the documentation example. Details of the written documentation will
be covered in another lesson. For now, it is good for the students to have an actual hard
copy of what they are expected to produce.
Slide 18: Tell Me / Show Me This Final Presentation Rubric will be used
Discuss the Final Presentation Rubric. Students must know what is expected and this may
help them make a committed choice of a topic.
Slide 19: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 20: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

6
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 12 Project Management: Final Presentation Checkpoint Lesson
Slide 1: Project Management: Final Presentation Checkpoint
Lesson Preparation
Most of the class time today should allow students to make progress on their project.
They need to refine and finalize their ERDs. A project-management tracking grid will be
presented to the students as a way to track their progress.
Print out copies of the final project-tracking grid for the students.
They will fill this out over the course of the project.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Why Learn It? (continued)
No instructor notes for this slide
Slide 5: Tell Me / Show Me A well-managed project has a better chance of
Hand out copies of the final project-tracking grid and review it with students.
Point out that this is a way to organize all the tasks that need to be done for the final
presentation.
Slide 6: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 7: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

7
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
PRACTICE SOLUTIONS
SECTION 12 SQL Introduction: Querying the Database Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Subset

A set contained within another set.

Modification

A change or revision.

Syntax

The rules governing the formation of statements in a


programming language.

Try It / Solve It
Basic SQL Commands
1. Your instructor will give you a copy of some basic SQL commands and will discuss
them with the class. Enter the commands in Oracle Application Express to see the
results.
a. Enter two or three rows of data with a new type (CLASSICAL, NEW AGE, JAZZ
your choice). Then retrieve only the rows of data with this new music type.
b. Experiment on your own with variations of the command retrieve different
columns and different rows (specific artists, types, etc.).
Solution: Give each student a copy of the basic SQL commands. Step through each
command with the students. Have them enter the command and experiment on their
own with variations of the commands provided.

Oracle Academy

8
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 12 Basic Table Modifications Lesson
Try It / Solve It
1. Add at least five new rows and two new columns to the MUSIC table. If you make
mistakes, use the DELETE and ALTER commands to correct them.
Solution: Suggest some new columns, such as rating (they can assign their own
rating system), comments, etc., but encourage students to make up their own. Note
that some students will want to add a column named song. Point out that song
would probably have multiple values, but they can call it example song, or bestselling song, etc. Have them recall the rules of data modeling at this point.
Students can get frustrated when commands don't work. Make sure they know how to
read the error messages. Don't be alarmed if they create something and delete it by
accident. The music.sql script can always recreate the original table and data.

Oracle Academy

9
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 12 Project Overview and Getting Started Lesson
Try It / Solve It
1. Decide on a topic for your group.
2. Discuss the specific business problems that you want to solve.
3. Start creating a first-cut ERD.
Solution: Advise students that they should limit the ERD to five to six entities. They
need to scope out their project realistically, because they have a little more than a week to
put everything together.

Oracle Academy

10
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 12 Project Management: Final Presentation Checkpoint Lesson
Try It / Solve It
1. Final Presentation Progress Report
Use the class time to make progress on your final presentation. Revise and finalize
your ERD. Make sure you have all attributes defined, UIDs identified, relationships
named and so on. Use subtypes, arcs and hierarchies if applicable.
2. Obtain a copy of the Final Presentation Project Tracking form from your teacher. Fill
in the project tracking grid to document your current progress.
Solution: Work with each group. Have them fill out their final project-tracking grid and
show you where they are in the project timeline.
Remind them that they will create database tables from their ERD in two days.
Note: If you feel your students will not have time to complete the database tables, you
may consider requiring only the ERD and all documentation. You will be able to assess
their progress and abilities.
The next lesson will discuss the system-development lifecycle. After that they will map
their ERDs to a table design and create the database tables using Oracle Application
Express.

Oracle Academy

11
Database Design
Copyright 2011, Oracle. All rights reserved.

Anatomy of a SQL Statement

Copyright 2011, Oracle. All rights reserved.

Anatomy of a SQL Statement

What Will I Learn?


Objectives
In this lesson, you will learn to:
Match projection, selection, and join with their
correct functions/ capabilities
Create a basic SELECT statement
Use the correct syntax to display all rows in a
table
Use the correct syntax to select specific
columns in a table, modify the way data is
displayed and/or perform calculations using
arithmetic expressions and operators

Copyright 2010, Oracle. All rights reserved.

Anatomy of a SQL Statement

What Will I Learn?


Objectives (continued)
Formulate queries using correct operator
precedence to display desired results
Define a null value
Demonstrate the effect null values create in
arithmetic expressions
Construct a query using a column alias

Copyright 2010, Oracle. All rights reserved.

Anatomy of a SQL Statement

Why Learn It?


SELECT Keyword
SELECT is one of the most important, if not
the most important keyword in SQL. You use
SELECT to retrieve information from the
database.
When you learn how to use SELECT, youve
opened the door to the database.

sdm_s16_l01_a01

Imagine a database containing information


about movies such as title, genre, studio,
producer, release date, series, country,
language, rating, running time, and so on.
What if you only wanted the titles of movies
created in India? The SELECT statement
allows you to search for specific data.

Copyright 2010, Oracle. All rights reserved.

Anatomy of a SQL Statement

Tell Me / Show Me
SELECT Statement
The SELECT statement retrieves information from the database.
The syntax for a SELECT statement is as follows:
SELECT <column_name(s)>
FROM <table_name>;

In its simplest form, a SELECT statement must include the


following:
A SELECT clause, which specifies the columns to be
displayed
A FROM clause, which specifies the table containing the
columns listed in the SELECT clause

Copyright 2010, Oracle. All rights reserved.

Anatomy of a SQL Statement

Tell Me / Show Me
Conventions
SELECT title
FROM d_songs;
Throughout this course, the following will be used:
A keyword refers to an individual SQL statement. For
example, SELECT and FROM are keywords.
A clause is a part of a SQL statement. For example, SELECT
title is a clause.
A statement is a combination of the two clauses. For example,
SELECT title FROM d_songs is a statement.

Copyright 2010, Oracle. All rights reserved.

Anatomy of a SQL Statement

Tell Me / Show Me
Capabilities of SELECT
Statements

Table 2: Projection

Projection: Used to choose


columns in a table
Selection: Used to choose
rows in a table
Table 2: Selection

Copyright 2010, Oracle. All rights reserved.

Anatomy of a SQL Statement

Tell Me / Show Me
Projection and Selection
SELECT salary
FROM employees
WHERE last_name like Smith;
Projection

Selection

ID

FIRST_NAME

LAST_NAME

SALARY

10

John

Doe

4000

20

Jane

Jones

3000

30

Sylvia

Smith

5000

40

Hai

Nguyen

6000

Copyright 2010, Oracle. All rights reserved.

Anatomy of a SQL Statement

Tell Me / Show Me
Joining Tables Together
Join: Used to
bring together
data that is stored
in different tables
by creating a link
between them.
You will learn
about joins later
in the course.

Join

Table 1

Copyright 2010, Oracle. All rights reserved.

Table 2

Anatomy of a SQL Statement

Tell Me / Show Me
Selecting All Columns
You can display all the
columns of data in a table
by using an asterisk
symbol (*) instead of a
column name in the
SELECT clause.
In the following example,
all the columns in the
d_songs table are
selected.

ID

TITLE

DURATIO
N

ARTIST

TYPE_CODE

45

Its Finally
Over

5 min

The Hobbits

12

46

Im Going
to Miss My
Teacher

2 min

Jane Pop

12

47

Hurrah for
Today

3 min

The Jubilant Trio

77

48

Meet Me at
the Altar

6 min

Bobby West

49

Lets
Celebrate

8 min

The Celebrants

77

50

All These
Years

10 min

Diana Crooner

88

SELECT *
FROM d_songs;

Copyright 2010, Oracle. All rights reserved.

10

Anatomy of a SQL Statement

Tell Me / Show Me
Selecting All
Columns (continued)
You can also display
all the columns in a
table by listing them
individually.

SELECT id, title,


duration, artist,
type_code
FROM d_songs;

ID

TITLE

DURATION

ARTIST

TYPE_CODE

45

Its Finally
Over

5 min

The Hobbits

12

46

Im Going to
Miss My
Teacher

2 min

Jane Pop

12

47

Hurrah for
Today

3 min

The Jubilant Trio

77

48

Meet Me at
the Altar

6 min

Bobby West

49

Lets
Celebrate

8 min

The Celebrants

77

50

All These
Years

10 min

Diana Crooner

88

Copyright 2010, Oracle. All rights reserved.

11

Anatomy of a SQL Statement

Tell Me / Show Me
Projecting Specific
Columns
If you want to PROJECT only
specific columns from a table
to be displayed, simply list
each of the column names
you want and separate each
name with a comma in the
SELECT clause.

ID

TITLE

ARTIST

45

Its Finally Over

The Hobbits

46

Im Going to Miss My
Teacher

Jane Pop

47

Hurrah for Today

The Jubilant Trio

48

Meet Me at the Altar

Bobby West

49

Lets Celebrate

The Celebrants

50

All These Years

Diana Crooner

SELECT id, title,


artist
FROM d_songs;

Copyright 2010, Oracle. All rights reserved.

12

Anatomy of a SQL Statement

Tell Me / Show Me
Using Arithmetic Operators
Using a few simple rules and guidelines, you can
construct SQL statements that are both easy to read
and easy to edit. Knowing the rules will make
learning SQL easy.

You may need to modify the way in which data is


displayed, perform calculations, or look at what-if
scenarios. For example, "What if every employee
was given a 5% raise? How would that affect our
yearly profit figures?"

Copyright 2010, Oracle. All rights reserved.

13

Anatomy of a SQL Statement

Tell Me / Show Me
Using Arithmetic Operators (continued)
These types of calculations are all possible using arithmetic
expressions. You are already familiar with arithmetic expressions
in mathematics:
add (+), subtract (-) , multiply (*) and divide (/).

Note that using these operators does not create new columns in
the tables or change the actual data values. The results of the
calculations will appear only in the output.

Copyright 2010, Oracle. All rights reserved.

14

Anatomy of a SQL Statement

Tell Me / Show Me
Using Arithmetic Operators
(continued)
The example shown uses the
addition operator to calculate a
salary increase of 300 for all
employees and displays a new
SALARY + 300 column in the
output.
SELECT last_name, salary,
salary + 300
FROM employees;

LAST_NAME

SALARY

SALARY + 300

King

24000

24300

Kochhar

17000

17300

De Haan

17000

17300

Whalen

4400

4700

Higgins

12000

12300

Gletz

8300

8600

Zlotkey

10500

10800

Abel

11000

11300

Taylor

8600

8900

Grant

7000

7300

Putting in blank spaces before and


after an arithmetic operator will not
affect the output.

Copyright 2010, Oracle. All rights reserved.

15

Anatomy of a SQL Statement

Tell Me / Show Me
Precedence in Arithmetic Operators
Precedence is the order in which Oracle evaluates
different operators in the same expression. When
evaluating an expression containing multiple
operators, Oracle evaluates operators with higher
precedence before evaluating those with lower
precedence. Oracle evaluates operators with equal
precedence from left to right within an expression.

Copyright 2010, Oracle. All rights reserved.

16

Anatomy of a SQL Statement

Tell Me / Show Me
Precedence in Arithmetic Operators (continued)
Arithmetic operators perform the mathematical operations
of Multiplication, Division, Addition and Subtraction. If
these operators appear together in an expression,
multiplication and division are evaluated first. So the order
is: * / + -.
An easy way to remember their operator precedence is the
mnemonic device:

My Dear Aunt Sally

Copyright 2010, Oracle. All rights reserved.

17

Anatomy of a SQL Statement

Tell Me / Show Me
Precedence in Arithmetic Operators (continued)
If operators within an expression are of the same
priority, then evaluation is done from left to right. You
can always use parentheses to force the expression
within parentheses to be evaluated first.

In the example tables shown on the next slide, what


are the differences in the output between the query
that used parentheses and the one that didn't?

Copyright 2010, Oracle. All rights reserved.

18

Anatomy of a SQL Statement

Tell Me / Show Me
Precedence in Arithmetic Operators (continued)
Operator Precedence
LAST_NAME

SALARY

12 * SALARY + 100

King

24000

288100

Kochhar

17000

204100

De Haan

17000

204100

Whalen

4400

52900

Higgins

12000

144100

LAST_NAME

SALARY

12 * (SALARY + 100)

Gietz

8300

99700

King

24000

289200

Kochhar

17000

205200

De Haan

17000

205200

Whalen

4400

54000

Higgins

12000

145200

Gietz

8300

100800

Using Parentheses

Copyright 2010, Oracle. All rights reserved.

19

Anatomy of a SQL Statement

Tell Me / Show Me
NULL Values
In SQL, NULL is an interesting word. To understand NULL,
you have to know what NULL is and what NULL is not. NULL
is a value that is unavailable, unassigned, unknown, or
inapplicable.

NULL is not the same as a zero or a space. In SQL, a zero is


a number, and a space is a character.
Sometimes, you dont know the value for a column. In a
database, you can store unknowns in your databases.
Relational databases use a placeholder called NULL or null
to represent these unknown values.

Copyright 2010, Oracle. All rights reserved.

20

Anatomy of a SQL Statement

Tell Me / Show Me
NULL Values
(continued)
If any column value
in an arithmetic
expression is null,
the result is null or
unknown.
If you try to divide by
null, the result is null
or unknown.
However, if you try to
divide by zero, you
get an error!

Salaries and Commissions


LAST_NAME

JOB_ID

SALARY

King

AD_PRES

24000

Kochhar

AD_VP

17000

De Haan

AD_VP

17000

Whalen

AD_ASST

4400

Higgins

AC_MGR

12000

.2

Gietz

AC_ACC
OUNT

8300

.3

Zlotkey

SA_MAN

10500

.2

Abel

SA_REP

11000

.15

Copyright 2010, Oracle. All rights reserved.

COMMISSION_
PCT

21

Anatomy of a SQL Statement

Tell Me / Show Me
NULL Values (continued)
SELECT last_name, job_id, salary,
commission_pct, salary*commission_pct
FROM employees;
Salaries and Commissions
LAST_NAME

JOB_ID

SALARY

COMMISSION_
PCT

SALARY*
COMMISSION_PCT

King

AD_PRES

24000

Kochhar

AD_VP

17000

De Haan

AD_VP

17000

Whalen

AD_ASST

4400

Higgins

AC_MGR

12000

.2

2100

Gietz

AC_ACCOUNT

8300

.3

3300

Zlotkey

SA_MAN

10500

.2

1720

Abel

SA_REP

11000

.15

1050

Copyright 2010, Oracle. All rights reserved.

22

Anatomy of a SQL Statement

Tell Me / Show Me
Aliases
An Alias is a way of renaming a column heading in the output.

Without aliases, when the result of a SQL statement is displayed,


the name of the columns displayed will be the same as the
column names in the table or a name showing a arithmetic
operation such as 12*(SALARY + 100).
You probably want your output to display a name that is easier to
understand, a more "friendly" name. Column aliases let you
rename columns in the output.

Copyright 2010, Oracle. All rights reserved.

23

Anatomy of a SQL Statement

Tell Me / Show Me
Aliases (continued)
There are several rules when using column aliases to format
output.
A column alias:
Renames a column heading
Is useful with calculations
Immediately follows the column name
May have the optional AS keyword between the column
name and alias
Requires double quotation marks if the alias contains
spaces, special characters or is case-sensitive

Copyright 2010, Oracle. All rights reserved.

24

Anatomy of a SQL Statement

Tell Me / Show Me
Using Column Aliases
The syntax for aliases is:
SELECT * |column|expr [ AS alias], .....
FROM
table;
NAME

Examples:
SELECT last_name AS name,
commission_pct AS comm
FROM
employees;

SELECT last_name "Name",


salary*12 AS "Annual Salary"
FROM
employees;

Copyright 2010, Oracle. All rights reserved.

COMM

King

Kochhar
De Haan

Name

Annual Salary

King

288000

Kochhar

204000

De Haan

204000

25

Anatomy of a SQL Statement

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Arithmetic expression
Arithmetic operator
Clause
Column
Column alias
From clause
Join
NULL
Projection
Select clause
Selection
Select statement
Statement

Copyright 2010, Oracle. All rights reserved.

26

Anatomy of a SQL Statement

Summary
Objectives Summarized
In this lesson, you have learned to:
Match projection, selection, and join with their correct
functions/capabilities
Create a basic SELECT statement
Use the correct syntax to display all rows in a table
Use the correct syntax to select specific columns in a table,
modify the way data is displayed and/or perform calculations
using arithmetic expressions and operators
Formulate queries using correct operator precedence to
display desired results
Define a null value
Demonstrate the effect null values create in arithmetic
expressions
Construct a query using a column alias
Copyright 2010, Oracle. All rights reserved.

27

Anatomy of a SQL Statement

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

28

Oracle Database Environment

Copyright 2011, Oracle. All rights reserved.

Oracle Database Environment

What Will I Learn?


In this lesson, you will learn to:
Explain the features and benefits that
the Oracle 11g Database Environment
provides for businesses
Locate information about Oracle
Corporation and its products and
services
Relate the steps in the system
development life cycle (SDLC) to the
development and design of the Oracle
11g Database product and the datamodeling process
sdm_s16_l02_a01

Copyright 2010, Oracle. All rights reserved.

Oracle Database Environment

Why Learn It?


Purpose
Have you ever wondered why product
manufacturers design new models every
year and consumers seek to buy them?
What have you purchased recently that is
an improvement over a previous product
you owned (a mobile phone, a mp3
player, a video game player).
Businesses like Oracle constantly seek to
develop new products to improve
information technology. As a member of
the Oracle Academy, you have the
opportunity to learn from one of the
world's leaders in information technology.
Copyright 2010, Oracle. All rights reserved.

Oracle Database Environment

Tell Me / Show Me
Application
Follow along as the instructor reads the article "The
Making of Oracle Database 10g" by Barbara Assidi.
Try to identify similarities between what the Oracle
Corporation experienced in developing their database
product and what you experienced in designing and
developing a database in data modeling.

Copyright 2010, Oracle. All rights reserved.

Oracle Database Environment

Tell Me / Show Me
Article Highlights
Highlights you should have noted from the article:
"The planning phase commenced about two years
before coding began."
"The biggest challenge isn't coming up with great ideas
to build into the database -- it's narrowing them down."
"Writing the code that comprises the Oracle database is
a disciplined activity that begins with the creation of a
Functional Specification Document -- a document that
provides details about each new feature of the
database, complete with architectural diagrams."

Copyright 2010, Oracle. All rights reserved.

Oracle Database Environment

Tell Me / Show Me
Article Highlights (continued)
Highlights you should have noted from the article
(continued):
"We had checkpoint meetings every six weeks to make
sure the development managers were on top of the
project and on schedule.
"Things don't always go as planned and these meetings
give us a chance to anticipate problems and respond
quickly to events."
"Early on, we developed a core document that distilled
the myriad features of the release into a statement of the
release's key messages."
"We spent a lot of time on the language."

Copyright 2010, Oracle. All rights reserved.

Oracle Database Environment

Tell Me / Show Me
System Development Life Cycle
The System Development Life Cycle (SDLC) is a step-bystep process that database developers use to transform the
information needs of a business into a working operational
database.

Copyright 2010, Oracle. All rights reserved.

Oracle Database Environment

Tell Me / Show Me
System Development Life Cycle (continued)
The steps in the SDLC include:
Strategy and analysis: Study and analyze the
business requirements; build the data models
Design: Map the design to tables
Build and document: Create the tables and the
user documentation
Transition: Test and refine the design; train users
Production: Roll out the system for the users

Copyright 2010, Oracle. All rights reserved.

Oracle Database Environment

Summary
Objectives Summarized
In this lesson, you have learned to:
Explain the features and benefits that the Oracle 11g
Database Environment provides for businesses
Locate information about Oracle Corporation and its
products and services
Relate the steps in the system development life cycle
(SDLC) to the development and design of the Oracle
11g Database product and the data-modeling process

Copyright 2010, Oracle. All rights reserved.

Oracle Database Environment

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

10

Using Applications

Copyright 2011, Oracle. All rights reserved.

Using Applications

What Will I Learn?


Objectives
In this lesson, you will learn to:
Distinguish between application software and system
software and give an example of each
Demonstrate use of Oracle Application Express to
enter SQL statements that retrieve data

Copyright 2010, Oracle. All rights reserved.

Using Applications

Why Learn It?


Purpose
Every day, in one way or another,
we come in contact with computer
applications.
If you checked your email today, it
was probably done using an
application. If you bought an item at
a grocery store, the clerk scanned
the item using an application that
calculated your bill and updated the
store inventory. In this course, you
will learn the syntax of SQL using
the application Oracle Application
Express.
Copyright 2010, Oracle. All rights reserved.

sdm_s16_l03_a01

Using Applications

Tell Me / Show Me
Application Programs
Although computers have been around since before you
were born, their use for business and personal computing
didn't take place until application software programs were
developed. Application programs allowed the end user,
people like you and me, to be able to buy fully developed,
ready-to-use programs. It was no longer necessary to
know how the program worked, just that it did work and
accomplished what we wanted it to do.

Copyright 2010, Oracle. All rights reserved.

Using Applications

Tell Me / Show Me
Application Programs (continued)
Application program software is different from system
software. System software consists of low-level
programs designed to interact with the computer
hardware. Operating systems, compilers, and system
utilities are examples of system software. In contrast,
application software includes programs for word
processing, databases, gaming, email, and graphics.

Copyright 2010, Oracle. All rights reserved.

Using Applications

Tell Me / Show Me
Application Programs (continued)
Yahoo.com uses the Oracle database
to store data. Rather than having
everyone who wants to search the
database or retrieve email learn SQL,
an application has all the SQL (and
other coding languages) preprogrammed into it. With a few mouse
clicks, users have access to all the
information they need.

Copyright 2010, Oracle. All rights reserved.

sdm_s16_l03_a02

Using Applications

Tell Me / Show Me
Using Applications
An application is like a car. To drive a car, you need to
know enough to make it work. It has a friendly shell to
hide all the things you dont need to know, such as how
the transmission works or how fuel like petrol or diesel is
used to make it run. Could you ever get your driver's
license if you had to know every detail of what makes a
car run?

Copyright 2010, Oracle. All rights reserved.

Using Applications

Tell Me / Show Me
Oracle Application Express
In this course, you will use Oracle Application Express.
This application enables many developers to build and
access applications as if they were running in separate
databases. With built-in features such as design themes,
navigational controls, form handlers, and flexible reports,
Oracle Application Express accelerates the application
development process.

Copyright 2010, Oracle. All rights reserved.

Using Applications

Tell Me / Show Me
Oracle Application Express (continued)
Oracle Application Express has three components:
SQL Workshop
Application Builder
Data Browser
To learn SQL, you will use the SQL Workshop component. To
design an application, you use Application Builder.
Your teacher will demonstrate how to use SQL Workshop so you
can get started learning SQL.

Copyright 2010, Oracle. All rights reserved.

Using Applications

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Application software
System software

Copyright 2010, Oracle. All rights reserved.

10

Using Applications

Summary
Objectives Summarized
In this lesson you have learned to:
Distinguish between application software and system
software and give an example of each
Demonstrate use of Oracle Application Express to
enter SQL statements that retrieve data

Copyright 2010, Oracle. All rights reserved.

11

Using Applications

Summary
Practice Guide
The link for the lesson practice guide can be
found in the course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

12

Relational Database Technology

Copyright 2011, Oracle. All rights reserved.

Relational Database Technology

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define and give an example of a relational database
Identify table-key terms, including row, column, field,
primary key, and foreign key
Relate the importance of databases to everyday life

Copyright 2010, Oracle. All rights reserved.

Relational Database Technology

Why Learn It?


Purpose
Databases are part of our everyday life even though most of the
time we don't even think about them.
If you have ever made an airline reservation, used an ATM
machine, or made a mobile-phone call, you've used a database.
In fact, many cities use intelligent traffic guiding system databases
to control stoplights. So the next time you're waiting at a red light,
it may be a database that is responsible for your delay!
In this lesson, you will learn more about databases and how
they're organized and created.

Copyright 2010, Oracle. All rights reserved.

Relational Database Technology

Tell Me / Show Me
Relational Databases
A relational database allows tables to be related by means of a
common field. As few as two tables can be considered a
relational database if they share a common field. Realistically,
databases used in business have many tables, each table
sharing a common field with another table. The D_SONGS table
shown is one of several tables in the DJs On Demand database
and just one example of the many tables that will be used in this
course.
ID

TITLE

ARTIST

45

Its Finally Over

The Hobbits

46

Im Going to Miss My
Teacher

Jane Pop

47

Hurrah for Today

The Jubilant Trio

48

Meet Me at the Altar

Bobby West

49

Lets Celebrate

The Celebrants

50

All These Years

Diana Crooner

Copyright 2010, Oracle. All rights reserved.

Relational Database Technology

Tell Me / Show Me
Relational Databases (continued)
To understand how important databases have become in today's
world, consider the following statistics:
Currently 20% of the world's data resides in RDBMSs.
In the next two years, databases are expected to grow larger
than 100 terabytes. A database this big would be able to store
100,000 copies of the Encyclopedia Britannica or 200,000
hours of music or about 10 billion web pages.
Some of the top 10 world's largest databases using the Oracle
RDBMS are:
France Telecom, 29.2TB -- a communications company (a TB is
a terabyte equivalent to 1,000 gigabytes)
Amazon.com with, 13 TB -- selling books and merchandise
The Claria Corporation,12TB -- Internet behavioral marketing
company tracking Internet user behavior

Copyright 2010, Oracle. All rights reserved.

Relational Database Technology

Tell Me / Show Me
Review Key Terms
Lets review the following key terms:
table -- basic storage structure
column -- one kind of data in a table
primary key -- unique identifier for each row
foreign key -- column that refers to a primary-key column
in another table
row -- data for one table instance
field -- the one value found at the intersection of a row
and a column

Copyright 2010, Oracle. All rights reserved.

Relational Database Technology

Tell Me / Show Me
Properties of Tables
There are six properties of tables in a relational database:
Property 1: Entries in columns are single-valued
Property 2: Entries in columns are of the same kind
Property 3: Each row is unique
Property 4: Sequence of columns is insignificant
Property 5: Sequence of rows is insignificant
Property 6: Each column has a unique name

Copyright 2010, Oracle. All rights reserved.

Relational Database Technology

Tell Me / Show Me
Accessing Data in an RDBMS
A relational database-management system (RDBMS)
organizes data into related rows and columns.
To access the data in a database, you do not need to know
where the data is located physically nor do you need to
specify an access route to the tables.
You simply use structured query language (SQL)
statements and operators.

Copyright 2010, Oracle. All rights reserved.

Relational Database Technology

Tell Me / Show Me
Communicating with Databases
Working with the database is very similar to calling up and
talking to a friend on the phone. First, you must choose a
method to communicate (the phone). Once connected, you
ask your friend a question (a query). In response to your
question, your friend answers (return of data). Pretty simple,
most of us are experts at this.
In this class, our method of communication with the
database will be through Oracle Application Express. When
you ask a question using SQL, the application will return an
answer.

Copyright 2010, Oracle. All rights reserved.

Relational Database Technology

Tell Me / Show Me
Communicating With Databases (continued)
As shown in the diagram, communicating with an RDBMS is
accomplished by entering a SQL statement in Oracle Application
Express. The request is then sent to the Oracle Server (a database
running on a computer), the request is processed and the data returned
is displayed. In very large database systems, many users, servers and
tables make up the RDBMS.
SQL statement is entered.
SELECT department_name
FROM
departments;

Statement is sent to the Oracle Server.

Oracle
server
Data is returned from the Oracle Server.

Copyright 2010, Oracle. All rights reserved.

10

Relational Database Technology

Tell Me / Show Me
Categories of SQL Statements
SQL statements are grouped into several categories
depending on the functions they perform. During this course,
you will learn how to use SQL to execute these statements.
The data retrieval statement retrieves data from the database
using the keyword SELECT.
There are four categories of SQL statements:
Data manipulation language (DML)
Data definition language (DDL)
Transaction control language (TCL)
Data control language (DCL)

Copyright 2010, Oracle. All rights reserved.

11

Relational Database Technology

Tell Me / Show Me
Categories of SQL Statements (continued)
Data manipulation language (DML)
DML statements begin with INSERT, UPDATE, DELETE or
MERGE and are used to modify the table data by entering
new rows, changing existing rows, or removing existing rows.
Data definition language (DDL)
DDL statements creates, changes, and removes data
structures from the database. The keywords CREATE,
ALTER, DROP, RENAME and TRUNCATE begin DDL
statements.

Copyright 2010, Oracle. All rights reserved.

12

Relational Database Technology

Tell Me / Show Me
Categories of SQL Statements (continued)
Transaction control language (TCL)
TCL statements are used to manage the changes made
by DML statements. Changes to the data are executed
using COMMIT, ROLLBACK and SAVEPOINT. TCL
changes can be grouped together into logical
transactions.
Data control language (DCL)
DCL keywords GRANT and REVOKE are used to give or
remove access rights to the database and the structures
within it.

Copyright 2010, Oracle. All rights reserved.

13

Relational Database Technology

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Data control language (DCL)
Data definition language (DDL)
Data manipulation language (DML)
Field
Foreign key
Primary key
Relational database
Row
Table
Transaction control (TCL)
Copyright 2010, Oracle. All rights reserved.

14

Relational Database Technology

Summary
Objectives Summarized
In this lesson, you have learned to:
Define and give an example of a relational database
Identify table-key terms, including row, column, field,
primary key, and foreign key
Relate the importance of databases to everyday life

Copyright 2010, Oracle. All rights reserved.

15

Relational Database Technology

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

16

Working with Columns, Characters, and


Rows

Copyright 2011, Oracle. All rights reserved.

Working with Columns, Characters, and Rows

What Will I Learn?


Objectives
In this lesson, you will learn to:
Apply the concatenation operator to link columns to other
columns, arithmetic expressions, or constant values to
create a character expression
Use column aliases to rename columns in the query result
Enter literal values of type character, number, or date into a
SELECT statement
Define and use DISTINCT to eliminate duplicate rows
Edit, execute, and save SQL statements in Oracle
Application Express

Copyright 2010, Oracle. All rights reserved.

Working with Columns, Characters, and Rows

Why Learn It?


Purpose
If you were writing an article about the Olympics, you might
want to know how many different countries and how many
different athletes from each country were being
represented.
Having to go through lists and lists of participant names
could be very tedious.
Fortunately, using SQL, your job could take less than a
minute.
In addition, you could format your output to read like a
sentence. You will find these SQL features very useful.

Copyright 2010, Oracle. All rights reserved.

Working with Columns, Characters, and Rows

Tell Me / Show Me
DESCRIBE
Use the DESCRIBE (DESC) command to
display the structure of a table.
DESCRIBE <table_name>;
DESC returns the table name, table schema,
tablespace name, indexes, triggers, constraints,
and comments, as well as the data types,
primary and foreign keys, and which columns
can be nullable.
Table

Name

Type

Length

Precisio
n

Scal
e

Prima
ry
Key

Nullabl
e

Copyright 2010, Oracle. All rights reserved.

Defau
lt

Comments

Working with Columns, Characters, and Rows

Tell Me / Show Me
DESCRIBE (continued)
DESC departments;
Table

Name

Type

Length

Precision

Scale

Primary Key

Nullable

Default

Comments

DEPAR
TMENT
S

DEPARTMENT
_ID

Number

DEPARTMENT
_NAME

Varchar2

MANAGER_ID

Number

Manager_id of a
department. Foreign
key to employee_id
column of employees
table...

LOCATION_ID

Number

Location id where a
department is
located. Foreign key
to location_id column
of locations table.

Primary key column


of departments table.

30

A not null column that


shows name of a
department...

This is important information when inserting new rows into a


table because you must know the type of data each column will
accept and whether or not the column can be left empty.
Copyright 2010, Oracle. All rights reserved.

Working with Columns, Characters, and Rows

Tell Me / Show Me
The Concatenation Operator
Concatenation means to connect or link together in a
series. The symbol for concatenation is 2 vertical bars
sometimes referred to as pipes. Columns on either side of
the || operator are combined to make a single output
column. The syntax is:
string1 || string2 || string_n
When values are concatenated, the resulting value is a
character string.

Copyright 2010, Oracle. All rights reserved.

Working with Columns, Characters, and Rows

Tell Me / Show Me
The Concatenation Operator (continued)
In SQL, the concatenation operator can link columns to other
columns, arithmetic expressions, or constant values to create a
character expression. The concatenation operator is used to create
readable text output.
In the following example, the department_id is concatenated to the
department_name.
SELECT department_id || department_name
FROM departments;
DEPARTMENT_ID||DEPARTMENT_NAME
10Administration
20Marketing
50Shipping
60IT

Copyright 2010, Oracle. All rights reserved.

Working with Columns, Characters, and Rows

Tell Me / Show Me
The Concatenation Operator (continued)
In this variation on the previous example, the || ' ' || is used to make
a space between the department_id and department_name. The
empty set of single quotation marks creates a space between the
column values.
SELECT department_id || '
FROM departments;

'

||department_name

DEPARTMENT_ID||''||DEPARTMENT_NAME
10 Administration
20 Marketing
50 Shipping
60 IT

Copyright 2010, Oracle. All rights reserved.

Working with Columns, Characters, and Rows

Tell Me / Show Me
Concatenation and Column Aliases
Column aliases are useful when using the
concatenation operator so that the column
heading does not appear as the default SELECT
line.
SELECT department_id || ' ' ||
department_name AS " Department
Info "
FROM departments;

Department Info
10 Administration
20 Marketing
50 Shipping
60 IT

DJs on Demand Clients


Hiram Peters
Serena Jones
Lauren Vigil

SELECT first_name ||' ' ||


last_name AS "DJs on Demand
Clients"
FROM d_clients;

Copyright 2010, Oracle. All rights reserved.

Working with Columns, Characters, and Rows

Tell Me / Show Me
Concatenation and Literal Values
A literal value is a fixed data value such as a character, number, or
date. The following are examples of literal values:
dollars
has a monthly salary of:
January 1, 2009
Using concatenation and literal values, you can create output that
looks almost like a sentence or statement.

Literal values can be included in the SELECT list with the


concatenation operator. Characters and dates must be enclosed in
a set of single quotes ' '. Every row returned from a query with
literal values will have the same character string in it.

Copyright 2010, Oracle. All rights reserved.

10

Working with Columns, Characters, and Rows

Tell Me / Show Me
Concatenation and Literal Values (continued)
In the following example, King earns 24000 dollars a month. The strings, 'has a
monthly salary of' and 'dollars. ', are examples of literals. If you were to create a
SQL statement to produce output in this format, it would be written as:
SELECT last_name ||' has a monthly salary of ' || salary
|| ' dollars.' AS Pay
FROM employees;
PAY
King has a monthly salary of 24000 dollars.
Kochhar has a monthly salary of 17000 dollars.
De Haan has a monthly salary of 17000 dollars.
Whalen has a monthly salary of 4400 dollars.
Higgins has a monthly salary of 12000 dollars.
Gietz has a monthly salary of 8300 dollars.

Note the spacing after and before the single quotes. What happens if you
remove the spaces?

Copyright 2010, Oracle. All rights reserved.

11

Working with Columns, Characters, and Rows

Tell Me / Show Me
Concatenation and Literal Values (continued)
You can also include numbers as literal values. In the following
example, the number 1 is concatenated to the strings, ' has a ' and '
year salary of '.
SELECT last_name ||
' has a ' || 1 ||
' year salary of ' ||
salary*12 || ' dollars.' AS Pay
FROM employees;
PAY
King has a 1 year salary of 288000 dollars.
Kochhar has a 1 year salary of 204000 dollars.
De Haan has a 1 year salary of 204000 dollars.
Whalen has a 1 year salary of 52800 dollars.
Higgins has a 1 year salary of 144000 dollars.

Copyright 2010, Oracle. All rights reserved.

12

Working with Columns, Characters, and Rows

Tell Me / Show Me
Using DISTINCT to Eliminate Duplicate Rows
There are many times when you want to know
how many unique instances of something exist.
For example, what if you wanted a list of all of
the departments for which there are employees?
You could write a query to select the
department_ids from the employees table:

DEPARTMENT_ID
90
90
90
10
110

SELECT department_id
FROM employees;

110

80
80
80

Note all of the duplicate rows. How can you


modify the statement to eliminate the duplicate
rows?

Copyright 2010, Oracle. All rights reserved.

13

Working with Columns, Characters, and Rows

Tell Me / Show Me
Using DISTINCT to Eliminate Duplicate Rows (continued)
Unless you indicate otherwise, the output of a SQL query will display the
results without eliminating duplicate rows. In SQL, the DISTINCT keyword
is used to eliminate duplicate rows.
SELECT DISTINCT department_id
FROM employees;

DEPARTMENT_ID

90
20
110
80
50

10
60

The DISTINCT qualifier affects all listed columns and returns every distinct
combination of the columns in the SELECT clause. The keyword
DISTINCT must appear directly after the SELECT keyword.
Copyright 2010, Oracle. All rights reserved.

14

Working with Columns, Characters, and Rows

Tell Me / Show Me
EXECUTE, SAVE, and EDIT
in Oracle Application Express
Now that you have been using Oracle Application Express to
create and execute statements, would it not be nice if you
could save those statements for later, so you could run them
again or perhaps edit them slightly and then save a new copy
of the statement?
Luckily for you, Oracle Application Express has facilities to
do just that. Your teacher will demonstrate these facilities for
you, and you can find further information in the Oracle
Application Express User Guide.

Copyright 2010, Oracle. All rights reserved.

15

Working with Columns, Characters, and Rows

Summary
Objectives Summarized
In this lesson, you have learned to:
Apply the concatenation operator to link columns to other
columns, arithmetic expressions, or constant values to
create a character expression
Use column aliases to rename columns in the query result
Enter literal values of type character, number, or date into a
SELECT statement
Define and use DISTINCT to eliminate duplicate rows
Edit, execute, and save SQL statements in Oracle
Application Express

Copyright 2010, Oracle. All rights reserved.

16

Working with Columns, Characters, and Rows

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

17

Limit Rows Selected

Copyright 2011, Oracle. All rights reserved.

Limit Rows Selected

What Will I Learn?


Objectives
In this lesson, you will learn to:
Apply SQL syntax to restrict the rows returned from a
query
Demonstrate application of the WHERE clause syntax
Explain why it is important, from a business
perspective, to be able to easily limit data retrieved
from a table
Construct and produce output using a SQL query
containing character strings and date values

Copyright 2010, Oracle. All rights reserved.

Limit Rows Selected

Why Learn It?


Purpose
Have you ever had information overload?
The television is on, your Mom is asking you how school
went today, the phone rings, and the dog is barking.
Wouldn't it be nice to be able to restrict the amount of
information you have to process at one time? In SQL, this
is the job of the WHERE clause.
It is important to be able to choose the information you
need to see from a table. Tables can have millions of rows
of data, and it is a waste of resources to search and return
data you don't need or want.

Copyright 2010, Oracle. All rights reserved.

Limit Rows Selected

Tell Me / Show Me
SELECT Statement
You use SELECT to retrieve information from the
database. A SELECT statement must include at a
minimum a SELECT clause and a FROM clause. The
WHERE clause is optional.

SELECT*|{[DISTINCT] column | expression alias]..}


FROM table
[WHERE condition(s)];

Copyright 2010, Oracle. All rights reserved.

Limit Rows Selected

Tell Me / Show Me
WHERE Clause
When retrieving data from the database, you may need to
limit the rows of data that are displayed. You can
accomplish this using the WHERE clause. A WHERE
clause contains a condition that must be met, and it
directly follows the FROM clause in a SQL statement.
The syntax for the WHERE clause is:
WHERE column_name comparison_condition
column_names, constants or list of values

Note: An alias cannot be used in the WHERE clause!

Copyright 2010, Oracle. All rights reserved.

Limit Rows Selected

Tell Me / Show Me
WHERE Clause (continued)
Examine the following SQL statement from the
DJs on Demand database:
SELECT id, first_name, last_name
FROM
d_partners;

ID

FIRST_
NAME

LAST_NAME

11

Jennifer

cho

22

Jason

Tsang

33

Allison

Plumb

Note how by adding a WHERE clause, the rows are limited to those
rows where the value of ID is 22.
SELECT first_name, last_name, expertise
FROM
d_partners
WHERE id=22;

Copyright 2010, Oracle. All rights reserved.

ID

FIRST_
NAME

LAST_NAME

22

Jason

Tsang

Limit Rows Selected

Tell Me / Show Me
Comparison Operators in the WHERE Clause
As you saw on the previous slide, the = sign can be used
in the WHERE clause. In addition to the equal to sign (=),
other comparison operators can be used to compare one
expression to a value or expression:
= equal to
> greater than
>= greater than or equal to
< less than
<= less than or equal to
<> not equal to (or != or ^=)

Copyright 2010, Oracle. All rights reserved.

Limit Rows Selected

Tell Me / Show Me
Comparison Operators in the WHERE Clause (continued)
In the example below, which column name is used in the
WHERE clause? What comparison operator is used? Is "90"
a column name or a constant?
SELECT employee_id, last_name, department_id
FROM
employees
WHERE department_id = 90 ;

Copyright 2010, Oracle. All rights reserved.

Limit Rows Selected

Tell Me / Show Me
Character and Date Strings in the WHERE clause
Character strings and dates in the WHERE clause must be
enclosed in single quotation marks ' ' . But this does NOT
make them literal strings. They are still just character and
date strings.
Numbers, however, should not be enclosed in single
quotation marks.
Look at the following example from the DJs on Demand
database. The WHERE clause contains a string and is
enclosed in single quotation marks.
SELECT first_name, last_name
FROM
d_clients
WHERE last_name = 'Jones';
Copyright 2010, Oracle. All rights reserved.

Limit Rows Selected

Tell Me / Show Me
Character and Date Strings in the WHERE Clause
(continued)
What do you think will happen if the WHERE clause is written
as:

WHERE last_name = 'jones';


All character searches are case-sensitive. Because the
D_CLIENTS table stores all the last names in the proper case,
no rows are returned.
This is an important point to remember. In another lesson, you
will learn to use other SQL keywords UPPER, LOWER and
INITCAP that will make it easier to avoid a case-sensitive
mistake.
Copyright 2010, Oracle. All rights reserved.

10

Limit Rows Selected

Tell Me / Show Me
Comparison Operators in the WHERE Clause
Comparison operators can be used in all of the following ways in
the WHERE clause:
WHERE event_date = '01-JAN-04'
WHERE rental_fee >=2000
WHERE cd_title = 'White Rose'
In the example shown from the DJs on Demand database, which
rows will be selected? Will salaries of 3000 be included in the
results set?
SELECT last_name, salary
FROM
employees
WHERE salary <= 3000;

Copyright 2010, Oracle. All rights reserved.

11

Limit Rows Selected

Summary
Objectives Summarized
In this lesson, you have learned to:
Apply SQL syntax to restrict the rows returned from a
query
Demonstrate application of the WHERE clause syntax
Explain why it is important, from a business
perspective, to be able to easily limit data retrieved
from a table
Construct and produce output using a SQL query
containing character strings and date values

Copyright 2010, Oracle. All rights reserved.

12

Limit Rows Selected

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

13

Comparison Operators

Copyright 2011, Oracle. All rights reserved.

Comparison Operators

What Will I Learn?


Objectives
In this lesson, you will learn to:
Apply the proper comparison operator to return a
desired result
Demonstrate proper use of BETWEEN, IN, and LIKE
conditions to return a desired result
Distinguish between zero and the value of NULL as
unavailable, unassigned, unknown, or inapplicable
Explain the use of comparison conditions and NULL

Copyright 2010, Oracle. All rights reserved.

Comparison Operators

Why Learn It?


Purpose
We use comparisons in everyday conversation without really
thinking about it.
"I can meet you BETWEEN 10:00 a.m. and 11:00 a.m."
"I'm looking for a pair of jeans LIKE the ones you are wearing."
"If I remember correctly, the best concert seats are IN rows
100, 200, and 300.
The need to express these types of comparisons also exists in
SQL. Comparison conditions are used to find data in a table
meeting certain conditions. Being able to formulate a SELECT
clause to return specific data is a powerful feature of SQL.

Copyright 2010, Oracle. All rights reserved.

Comparison Operators

Tell Me / Show Me
Comparison Operators
You are already familiar with the comparison operators such
as equal to (=), less than (<) and greater than (>). SQL has
other operators that add functionality for retrieving specific
sets of data. These include:
BETWEENAND
IN
LIKE

Copyright 2010, Oracle. All rights reserved.

Comparison Operators

Tell Me / Show Me
BETWEEN...AND
The BETWEEN...AND operator is used to select and
display rows based on a range of values. When used with
the WHERE clause, the BETWEEN...AND condition will
return a range of values between the specified lower and
upper limits and include both values.

Copyright 2010, Oracle. All rights reserved.

Comparison Operators

Tell Me / Show Me
BETWEENAND (continued)
Note in the example from the DJs on Demand database the
values returned include the lower-limit value and the upperlimit value. Values specified with the BETWEEN condition
are said to be inclusive. Note also that the lower-limit value
must be listed first.
SELECT title, year
FROM
d_cds
WHERE year BETWEEN 1999 AND 2001;

Note that the output included the


lower-limit and upper-limit values.

TITLE

YEAR

Party Music for All


Occasions

2000

Songs from My
Childhood

1999

Carpe Diem

2000

Here Comes the


Bride

2001

Copyright 2010, Oracle. All rights reserved.

Comparison Operators

Tell Me / Show Me
BETWEENAND (continued)
Using BETWEEN...AND is the same as using the
following expression:
WHERE year >= 1999 AND year <= 2001

In fact, there is no performance benefit using


BETWEEN...AND or the alternate comparison operators.
We use BETWEEN...AND for simplicity in reading the
code and getting the results from the database.

Copyright 2010, Oracle. All rights reserved.

Comparison Operators

Tell Me / Show Me
IN
The IN condition is also known as the "membership
condition." It is used to test whether a value is in a specified
set of values. For example, IN could be used to identify
students whose identification numbers are 2349, 7354 or
4333 or people whose international phone calling code is
1735, 82 or 10.
SELECT title, type_code
FROM d_songs
WHERE type_code IN (77,12);

TITLE

TYPE_CODE

Its Finally Over

12

Im Going to Miss My Teacher

12

Hurrah for Today

77

Lets Celebrate

77

Copyright 2010, Oracle. All rights reserved.

Comparison Operators

Tell Me / Show Me
IN (continued)
In this example, the WHERE clause could also be written
as a set of OR conditions:
SELECT title, type_code
FROM
d_songs
WHERE type_code IN ( 77, 12 );

WHERE type_code = 77 OR type_code = 12;


As with BETWEEN...AND the IN condition can be written
using either syntax.

Copyright 2010, Oracle. All rights reserved.

Comparison Operators

Tell Me / Show Me
LIKE
Have you ever gone shopping to look for something like
something you saw in a magazine or on television but you
weren't sure of the exact item? It's much the same with database
searches.
A manager may know that an employee's last name starts with
"S" but doesn't know the employees entire name. Fortunately, in
SQL, the LIKE condition allows you to select rows that match
either characters, dates or number patterns.
Two symbols -- the (%) and the underscore (_) -- called wildcard
characters, can be used to construct a search string.

Copyright 2010, Oracle. All rights reserved.

10

Comparison Operators

Tell Me / Show Me
LIKE (continued)
The percent (%) symbol is used to represent any sequence of
zero or more characters. The underscore (_) symbol is used to
represent a single character.

In the example shown below, all employees with last names


beginning with any letter followed by an "o" and then followed by
any other number of letters will be returned.
SELECT last_name
FROM
employees
WHERE last_name LIKE '_o%';

Copyright 2010, Oracle. All rights reserved.

11

Comparison Operators

Tell Me / Show Me
LIKE (continued)
SELECT last_name
FROM
employees
WHERE last_name LIKE '_o%';
Which of the following last names could have been
returned from the above query?
1. Sommersmith
2. Oog
3. Fong
4. Mo
If you said 1, 2, 3 and 4 you are correct!
Copyright 2010, Oracle. All rights reserved.

12

Comparison Operators

Tell Me / Show Me
LIKE (continued)
One additional option that is important: When you need to have
an exact match for a string that has a % or _ character in it, you
will need to indicate that the % or the _ is not a wildcard but is
part of the item you're searching for. The ESCAPE option
backward slash (\) is used to indicate that the underscore or %
is part of the name, not a wildcard value.
For example, if the database had stored CD track numbers as
TRA_6, the WHERE clause would need to be written as:
WHERE track LIKE 'TRA\_%'

Copyright 2010, Oracle. All rights reserved.

13

Comparison Operators

Tell Me / Show Me
IS NULL, IS NOT NULL
Remember NULL? It is the value that is unavailable, unassigned,
unknown, or inapplicable. Being able to test for unavailable,
unassigned, or unknown is often desirable. You may want to
know all the dates in June that, right now, do not have a concert
scheduled. You may want to know all of the clients who do not
have phone numbers recorded in your database.
The IS NULL condition tests for unavailable, unassigned, or
unknown data. IS NOT NULL tests for data that is present in the
database. In the example on the next slide, the WHERE clause is
written to retrieve all the last names and manager IDs of those
employees who do not have a manager.

Copyright 2010, Oracle. All rights reserved.

14

Comparison Operators

Tell Me / Show Me
IS NULL, IS NOT NULL (continued)
SELECT last_name, manager_id
FROM
employees
WHERE manager_id IS NULL;
Read the following and explain what you
expect will be returned:
SELECT first_name,
last_name,auth_expense_amt
FROM d_partners
WHERE auth_expense_amt IS NULL;
Copyright 2010, Oracle. All rights reserved.

15

Comparison Operators

Summary
Objectives Summarized
In this lesson, you have learned to:
Apply the proper comparison operator to return a
desired result
Demonstrate proper use of BETWEEN, IN, and LIKE
conditions to return a desired result
Distinguish between zero and the value of NULL as
unavailable, unassigned, unknown, or inapplicable
Explain the use of comparison conditions and NULL

Copyright 2010, Oracle. All rights reserved.

16

Comparison Operators

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

17

Oracle Academy
Database Design
Instructor Resource Guide
INSTRUCTOR NOTES
SECTION 16 Working with Columns, Characters and Rows Lesson
Slide 1: Working with Columns, Characters and Rows
Lesson Preparation
Any time students have extra time in class, have them work on the Self Test software
Practice Test Learning Mode questions. Select the question set appropriate for the
objectives currently being studied. For example, the first set of questions assess Writing
Basic SQL Select Statements. The Self Test questions can be challenging, but are
designed to test understanding of basic concepts, not simply SQL facts.
What to Watch For
As the SQL syntax becomes more complicated, make sure students understand each
concept. To monitor student progress in completing the practice exercises, you can:
Randomly choose three or four questions and ask students to copy the SQL
statement into Notepad, print it, and turn it in for grading.
Use the teacher access to each student's schema in Oracle Application Express.
Ask students to save three or four practices as Practice Section X, Lesson Y in
the Archive section. Review the query examples in each student's saved Archive.
Ask one or two students to write the answers to selected questions on the board.
Take time for students to review all the tables used in the DJ on Demand, Global Fast
Foods, and Oracle databases. Developing a mental picture of the tables will help them be
better able to formulate more difficult queries in the future.
Slide 2: What Will I Learn?
Read the objectives. Pronounce concatenation kon-kat-uh-NAY-shuhn the state of
being linked together as in a chain; union in a linked series.
Slide 3: Why Learn It?
If time permits ask students to find tables from original sources such as the newspaper or
Internet. Show the tables to the class and have students verbally construct SELECT
statements from them. Make it a game. Give two examples they can use with their class
and leave them in this section.
See www.wri.org/facts/data-tables.html for all kinds of tables that could make good
practice with real data.

Oracle Academy

1
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 4: Tell Me / Show Me DESCRIBE
Before beginning this lesson, use a simple SQL statement to demonstrate how to edit,
execute, and save SQL statements to files in Oracle Application Express. SQL statements
are saved in the Archive file and can be accessed from clicking the SQL tab in the menu
bar and then clicking the Archive tab.
Slide 5: Tell Me / Show Me DESCRIBE (continued)
Explain DESCRIBE or DESC and have students use Oracle Application Express to
describe a table in any database. Show students where the pipe (|) character is on their
keyboard. Make up sentences that students must display using the concatenation
operator. Demonstrate that leaving a space after or before the single quotation mark also
creates a space between words. Point out that an alias will eliminate the SELECT line
appearing as the column heading. Run the example twice, the second time with an alias
called Event to show the difference.
Using the DJ on Demand EVENT table, create and display:
On date, the event was name
Answer:
SELECT 'On ' ||event_date || ' the event was ' ||name
FROM d_events
Slide 6: Tell Me / Show Me CONCATENATION
Demonstrate several errors to show students how to read the error statements. This will
help eliminate the mine doesn't work frustration.
Spell SELECT as SELCT.
Omit FROM.
In FROM use a column name instead of a table name.
SELECT a table that does not exist in the database.
Misspell a column name.
Fail to leave a space after SELECT and the column name.
SELECT several columns but omit the comma between column names.
Slide 7: Tell Me / Show Me CONCATENATION & COLUMN ALIASES
No instructor notes for this slide
Slide 8: Tell Me / Show Me CONCATENATION & COLUMN ALIASES (continued)
No instructor notes for this slide
Slide 9: Tell Me / Show Me CONCATENATION & COLUMN ALIASES (continued)
No instructor notes for this slide

Oracle Academy

2
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 10: Tell Me / Show Me CONCATENATION & COLUMN ALIASES (continued)
No instructor notes for this slide
Slide 11: Tell Me / Show Me CONCATENATION & COLUMN ALIASES (continued)
Remind students that numbers do not have to be enclosed in single quotes.
Slide 12: Tell Me / Show Me DISTINCT
No instructor notes for this slide
Slide 13: Tell Me / Show Me DISTINCT (continued)
Discuss the graphic and identify the number of DISTINCT colors there are.
Slide 14: Tell Me / Show Me DISTINCT (continued)
In the band_logo and color example, ask students to list all the different combinations
there are with logos and colors: six different distinct combinations (2 bands * 3 shirt
colors).
Students will not be able to execute the band_logo and color query.
Slide 15: Tell Me / Show Me EXECUTE, SAVE AND EDIT STATEMENTS IN OAE
No instructor notes for this slide
Slide 16: Summary In this lesson you have learned about:
No instructor notes for this slide
Slide 17: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

3
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 16 Limit Rows Selected Lesson
Slide 1: Limit Rows Selected
What to Watch For
Adding the WHERE clause is the first step in beginning to build more complicated
SELECT statements. It is critical that students understand how to construct a basic
SELECT statement at this point.
Connections
Give students or ask students for other examples where we restrict data in our everyday
lives. When you go shopping, do you go to a store planning to buy one of everything in
that store? No, you select certain items to buy. Your sales receipt will list the selection of
items you purchased, not all the items in the store. Why do grocery stores put signs above
the aisles? (Possible answer: so you can limit your search) Why are similar items in the
grocery store shelved together? Imagine having all items in the grocery store placed on
any shelf in any location. Isn't it easier to select the beverage aisle and see all the sodas in
one place? Did the signs help limit our search?
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Tell Me / Show Me SELECT Statement
Review the SELECT clause general syntax. The [ ] mean this is optional. The | means
or.
Slide 5: Tell Me / Show Me WHERE Clause
No instructor notes for this slide
Slide 6: Tell Me / Show Me WHERE Clause (continued)
What is the column name used in the WHERE clause? department_id
What comparison operator is used? =
Is 90 a column name or a constant? constant or data value
Slide 7: Tell Me / Show Me Comparison Operators in the WHERE Clause
What is the column name used in the WHERE clause? department_id
What comparison operator is used? =
Is 90 a column name or a constant? constant or data value
Slide 8: Tell Me / Show Me Comparison Operators in the WHERE Clause (continued)
No instructor notes for this slide
Oracle Academy

4
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 9: Tell Me / Show Me Character and Date Strings in the WHERE Clause
(continued)
No instructor notes for this slide
Slide 10: Tell Me / Show Me Character and Date Strings in the WHERE Clause
(continued)
No instructor notes for this slide
Slide 11: Tell Me / Show Me Comparison Operators in the WHERE clause
In the example, explain that < = means 3000 will be selected. Give other examples with
>= and <>.
Slide 12: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 13: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

5
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 16 Comparison Operators Lesson
Slide 1: Comparison Operators
Lesson Preparation
Ask students to find examples in the newspaper, online, or in another textbook that use
the BETWEEN...AND or LIKE conditions. Rewrite the sentence using SQL syntax.
For example, in this excerpt from a poem by Carl Sandburg called Prairie, you could
say...
Here between the sheds of the Rocky Mountains and the Appalachians, here now a
morning star fixes a fire sign over the timber claims and cow pastures, the corn belt, the
cotton belt, the cattle ranches....
WHERE prairie BETWEEN the sheds of the Rocky Mountains AND the Appalachians
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Tell Me / Show Me COMPARISON OPERATORS
In the syntax introduced in this lesson, the WHERE clause has become more complex.
Explain to students that the WHERE clause can be used to select for combinations of
values. For example, I would like to know Global Fast Foods employees whose manager
ID is 19 and earn a salary less than $12.00 per hour.
SELECT *
FROM f_staffs
WHERE manager_id = 19 and salary <12.00;
Slide 5: Tell Me / Show Me BETWEENAND
Note that the year column is defined as a VARCHAR2 datatype. Because of this, the
SQL statement could have been written without quotes around the year values:
SELECT title, year
FROM d_cds
WHERE year BETWEEN 1999 AND 2001;
The reason for this is because when Oracle compares a numeric literal (i.e., 1999) against
a VARCHAR2 column, Oracle implicitly converts the data into a character
(VARCHAR2) datatype. But it will slow down the execution of the statement slightly, so
it is best to be as accurate as possible when writing SQL statements.
Check to make sure students understand the term inclusive when used with
BETWEEN...AND.

Oracle Academy

6
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 6: Tell Me / Show Me BETWEENAND (continued)
No instructor notes for this slide
Slide 7: Tell Me / Show Me BETWEENAND (continued)
No instructor notes for this slide
Slide 8: Tell Me / Show Me IN
Explain membership condition to students and ask them to give an example. Possible
responses: The membership condition for being IN this year's graduating class is that you
must have completed all course credit requirements.
Slide 9: Tell Me / Show Me IN (continued)
No instructor notes for this slide
Slide 10: Tell Me / Show Me LIKE
No instructor notes for this slide
Slide 11: Tell Me / Show Me LIKE (continued)
No instructor notes for this slide
Slide 12: Tell Me / Show Me LIKE (continued)
No instructor notes for this slide
Slide 13: Tell Me / Show Me LIKE (continued)
Review the BETWEEN...AND, IN, and LIKE conditions. As each syntax is introduced,
have students generate examples for class practice. For example, from the DJs on
Demand database give me all producers where the producer begins with T.
SELECT producer
FROM d_cds
WHERE producer LIKE 'T%';
Slide 14: Tell Me / Show Me IS NULL, IS NOT NULL
Discuss the concept of NULL and the difference between values that are unknown,
values that are unknowable, and values that are inapplicable.
Where does the sky end? Is it unknown, unknowable, or inapplicable?
Slide 15: Tell Me / Show Me IS NULL, IS NOT NULL (continued)
Discuss the concept of NULL and the difference between values that are unknown,
values that are unknowable, and values that are inapplicable. Expected result will be three
columns where the auth_expense_amt column is null.
Ask your students to tell you if the following expression is true or false: x > y. And only
tell them that x=5. As long as y is unknown they cannot possibly answer that question.

Oracle Academy

7
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 16: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 17: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

8
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
PRACTICE SOLUTIONS
SECTION 16 Working with Columns, Characters and Rows Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
DISTINCT

A command that suppresses duplicates

Concatenation

Links two columns together to form one character


data column

String

A group of character data

DESCRIBE (DESC)

An SQL plus command that displays the structure of


a table

Try It / Solve It
1. The manager of Global Fast Foods would like to send out coupons for the upcoming
sale. He wants to send one coupon to each household. Create the SELECT statement
that returns the customer last name and a mailing address.
Solution: SELECT DISTINCT last_name, address,city, state, zip FROM
f_customers;
2. Each statement below has errors. Correct the errors and execute the query in Oracle
Application Express.
a.
SELECT first name
FROM f_staffs;
b.
SELECT first_name |" " | last_name AS "DJs on Demand Clients"
FROM d_clients;
c.
SELECT DISCTINCT f_order_lines
FROM quantity;

Oracle Academy

9
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
d.
SELECT order number
FROM f_orders;
Solution:
a. Missing underscore first_name
b. Incorrect single bar concatenation operator and double quotation marks
c. DISTINCT incorrectly spelled and column and table names in wrong place
d. Missing underscore order_number
3. Sue, Bob, and Monique were the employees of the month. Using the f_staffs table,
create a SELECT statement to display the results as shown in the Super Star chart.
Super Star
*** Sue *** Sue ***
*** Bob *** Bob ***
*** Monique *** Monique ***
Solution:
SELECT '***'||first_name ||'***'||first_name||'***' AS "Super Star" FROM f_staffs;
4. Which of the following is TRUE about the following query?
SELECT first_name, DISTINCT birthdate
FROM f_staffs;
a.
b.
c.
d.

Only two rows will be returned.


Four rows will be returned.
Only Fred 05-JAN-88 and Lizzie 10-NOV-87 will be returned.
No rows will be returned.

Solution:
d. No rows will be returned. DISTINCT must appear directly after SELECT.

Oracle Academy

10
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
5. Global Fast Foods has decided to give all staff members a 5% raise. Prepare a report
that presents the output as shown in the chart.
EMPLOYEE LAST NAME

CURRENT SALARY

SALARY WITH 5% RAISE

Solution:
SELECT last_name AS "EMPLOYEE LAST NAME", salary AS "CURRENT
SALARY",salary * 1.05 AS "SALARY WITH 5% RAISE"
FROM f_staffs ;
6. Create a query that will return the structure of the Oracle database EMPLOYEES
table. Which columns are marked nullable? What does this mean?
Solution:
DESCRIBE employees;
FIRST_NAME, PHONE_NUMBER, SALARY, COMMISSION_PCT,
MANAGER_ID, DEPARTMENT_ID
Nullable means that when data is entered into those columns, they can have NO
VALUE. Null is not 0, or a space, but an unknowable value.
7. The owners of DJs on Demand would like a report of all items in their D_CDs table
with the following column headings: Inventory Item, CD Title, Music Producer, and
Year Purchased. Prepare this report.
Solution:
SELECT cd_number AS "Inventory Item", title AS "CD Title", producer AS "Music
Producer", year AS "Year Purchased" FROM d_cds ;
8. True/False The following SELECT statement executes successfully:
SELECT last_name, job_id, salary AS Sal
FROM employees;
Solution: True
9. True/False The following SELECT statement executes successfully:
SELECT *
FROM job_grades;
Solution: True

Oracle Academy

11
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
10. There are four coding errors in this statement. Can you identify them?
SELECT employee_id, last_name
sal x 12 ANNUAL SALARY
FROM employees;
Solution:
Missing comma after last_name, sal*12 and "ANNUAL SALARY", sal should be
salary
11. In the arithmetic expression salary*12 - 400, which operation will be evaluated first?
Solution: Salary * 12
12. Which of the following can be used in the SELECT statement to return all columns of
data in the Global Fast Foods f_staffs table?
a. column names
b. *
c. DISTINCT id
d. both a and b
Solution: d.
13. Using SQL to choose the columns in a table uses which capability?
a. selection
b. projection
c. partitioning
d. join
Solution: b. projection
14. SELECT department_id, first_name, last_name AS "Employee". The column heading
in the query result will appear as:
a. EMPLOYEE
b. employee
c. Employee
d. "Employee:
Solution: c. Employee

Oracle Academy

12
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
15. Which expression below will produce the largest value?
a. SELECT salary*6 + 100
b. SELECT salary* (6 + 100)
c. SELECT 6(salary+ 100)
d. SELECT salary+6*100
Solution:
b. SELECT salary* (6 + 100)
16. Which statement below will return a list of employees in the following format?
Mr./Ms. Steven King is an employee of our company.
a. SELECT "Mr./Ms."||first_name||' '||last_name 'is an employee of our company.'
AS "Employees"
FROM employees;
b. SELECT 'Mr./Ms. 'first_name,last_name ||' '||'is an employee of our company.'
FROM employees;
c. SELECT 'Mr./Ms. '||first_name||' '||last_name ||' '||'is an employee of our company.'
AS "Employees"
FROM employees ;
d. SELECT Mr./Ms. ||first_name||' '||last_name ||' '||"is an employee of our company."
AS "Employees"
FROM employees
Solution:
c. SELECT 'Mr./Ms. '||first_name||' '||last_name ||' '||'is an employee of our company.'
AS "Employees" FROM employees ;
17. Which is true about SQL statements?
a. SQL statements are case-sensitive
b. SQL clauses should not be written on separate lines.
c. Keywords cannot be abbreviated or split across lines.
d. SQL keywords are typically entered in lowercase; all other words in uppercase.
Solution:
c. Keywords cannot be abbreviated or split across lines.

Oracle Academy

13
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
18. Which queries will return three columns each with UPPERCASE column headings?
a. SELECT "Department_id", "Last_name", "First_name"
FROM employees;
b. SELECT DEPARTMENT_ID, LAST_NAME, FIRST_NAME
FROM employees;
c. SELECT department_id, last_name, first_name AS UPPER CASE
FROM employees
d. SELECT department_id, last_name, first_name
FROM employees;
Solution:
b. SELECT DEPARTMENT_ID, LAST_NAME, FIRST_NAME FROM employees;
d. SELECT department_id, last_name, first_name FROM employees;
19. Which statement below will likely fail?
a. SELCT * FROM employees;
b. Select * FROM employees;
c. SELECT * FROM EMPLOYEES;
d. SelecT* FROM employees;
Solution:
a. SELCT * FROM employees;
20. Click on the History link at the bottom of the SQL Commands window. Scroll or use
the arrows at the bottom of the page to find the statement you wrote to solve problem
3 above. (The one with the column heading SuperStar). Click on the statement to
load it back into the command window. Execute the command again, just to make
sure it is the correct one that works. Once you know it works, click on the SAVE
button in the top right corner of the SQL Commands window, and enter a name for
your saved statement. Use your own initials and _superstar.sql, so if your initials
are CT then the filename will be CT_superstar.sql.
Log out of OAE, and log in again immediately. Navigate back to the SQL Commands
window, click the Saved SQL link at the bottom of the page and load your saved SQL
statement into the Edit window. This is done by clicking on the script name. Edit the
statement, to make it display + instead of *. Run your amended statement and save it
as initials_superplus.sql.

Oracle Academy

14
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 16 Limit Rows Selected Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
WHERE clause

Restricts the rows returned by a select statement

Comparison conditions

Compares one expression to another value or


expression

Try It / Solve It
1. Using the Global Fast Foods database, retrieve the customers first name, last name,
and address for the customer who uses ID 456.
Solution:
SELECT first_name, last_name, address
FROM f_customers
WHERE Id = 456;
2. Show the name, start date, and end date for Global Fast Foods' promotional item
ballpen and highlighter giveaway.
Solution:
SELECT name, start_date, end_date, give_away
FROM f_promotional_menus
WHERE give_away = 'ballpen and highlighter';
3. Create a SQL statement that produces the following output:

Oldest
The 1997 recording in our database is The Celebrants Live in Concert
Solution:
SELECT 'The 1997 recording in our database is ' ||title AS "Oldest"
FROM d_cds
WHERE year = 1997;

Oracle Academy

15
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
4. The following query was supposed to return the CD title "Carpe Diem" but no rows
were returned. Correct the mistake in the statement and show the output.
SELECT produce, title
FROM d_cds
WHERE title = 'carpe diem' ;
Solution:
SELECT producer, title
FROM d_cds
WHERE title = 'Carpe Diem';
5. The manager of DJ on Demand would like a report of all the CD titles and years of
CDs that were produced before 2000.
Solution:
SELECT title, year
FROM d_cds
WHERE year < 2000;
6. Which values will be selected in the following query?
SELECT salary
FROM employees
WHERE salary < = 5000;
a.
b.
c.
d.

5000
0 - 4999
2500
5

Solution:
All will be selected

Oracle Academy

16
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
For the next three questions, use the following table information:
TABLE NAME: students
COLUMNS: studentno NUMBER(6)
fname VARCHAR2(12)
lname VARCHAR(20)
sex CHAR(1)
major VARCHAR2(24)
7. Write a SQL statement that will display the student number (studentno), first name
(fname), and last name (lname) for all students who are female (F) in the table named
students.
Solution:
SELECT student_id, fname, lname
From students where sex = 'F';
8. Write a SQL statement that will display the student number (studentno) of any
student who has a PE major in the table named students. Title the studentno column
Student Number.
Solution:
SELECT studentno AS "Student Number" (AS is optional)
FROM students
WHERE major = 'PE' ;
9. Write a SQL statement that lists all information about all male students in the table
named students.
Solution:
SELECT *
FROM students
WHERE sex = 'M';
10. Write a SQL statement that will list the titles and years of all the DJs on Demand's
CDs that were not produced in 2000.
Solution:
SELECT title, year
FROM d_cds
WHERE year != 2000 ; (or ^= or <> );

Oracle Academy

17
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
11. Write a SQL statement that lists the Global Fast Foods employees who were born
before 1980.
Solution:
SELECT first_name, last_name
FROM f_staffs
WHERE birthdate < '01-JAN-80';

Oracle Academy

18
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 16 Comparison Operators Lesson
Vocabulary
ESCAPE

This option identifies that the escape characters


should be interpreted literally

IS NULL

Condition tests for null values

BETWEEN

Displays rows based on a range of values

Inclusive

Including the specified limits and the area between


them; the numbers 1-10, inclusive

LIKE

Selects rows that match a character pattern

IN

Tests for values in a specified list of values

Try It / Solve It
1. Display the first name, last name, and salary of all Global Fast Foods staff whose
salary is between $5.00 and $10.00 per hour.
Solution:
SELECT first_name, last_name, salary
FROM f_staffs
WHERE salary BETWEEN 5.00 and 10.00;
2. Display the location type and comments for all DJs on Demand venues that are
Private Home.
Solution:
SELECT loc_type, comments
FROM d_venues
WHERE loc_type = 'Private Home';

Oracle Academy

19
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
3. Using only the less than, equal, or greater than operators, rewrite the following query:
SELECT first_name, last_name
FROM f_staffs
WHERE salary BETWEEN 20.00 and 60.00;
Solution:
SELECT first_name, last_name
FROM f_staffs
WHERE salary >= 20 and salary <=60;
4. Create a list of all the DJs on Demand CD titles that have a as the second letter in
the title.
Solution:
SELECT title
FROM d_cds
WHERE title LIKE '_a%';
5. Who are the partners of DJs on Demand who do not get an authorized expense
amount?
Solution:
SELECT first_name, last_name
FROM d_partners
WHERE auth_expense_amt IS NULL;
6. Select all the Oracle database employees whose last names end with s Change the
heading of the column to read Possible Candidates.
Solution:
SELECT last_name AS "Possible Candidates"
FROM employees
WHERE last_name LIKE '%s';

Oracle Academy

20
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
7. Which statement(s) are valid?
a. WHERE quantity <> NULL;
b. WHERE quantity = NULL;
c. WHERE quantity IS NULL;
d. WHERE quantity != NULL;
Solution:
c. WHERE quantity IS NULL;
8. Write a SQL statement that lists the songs in the DJs on Demand inventory that are
type code 77, 12 or 1.
Solution:
SELECT title
FROM d_songs
WHERE type_code IN ( 77,12,1);

Oracle Academy

21
Database Design
Copyright 2011, Oracle. All rights reserved.

Logical Comparisons
and Precedence Rules

Copyright 2011, Oracle. All rights reserved.

Logical Comparisons and Precedence Rules

What Will I Learn?


Objectives
In this lesson, you will learn to:
Evaluate logical comparisons to restrict the rows
returned based on two or more conditions
Apply the rules of precedence to determine the order
in which expressions are evaluated and calculated

Copyright 2010, Oracle. All rights reserved.

Logical Comparisons and Precedence Rules

Why Learn It?


Purpose
Not too many things in life depend on
just one condition.
For instance, if you want to go to college,
you probably need good grades and the
tuition money to pay for it.
sdm_s18_l01_a01

If you have extra money, you could either


save it or spend it.
If you want to go to a movie, you may not
want to go this weekend and you may
not want to sit in the first 10 rows of the
theater.
Copyright 2010, Oracle. All rights reserved.

Logical Comparisons and Precedence Rules

Why Learn It?


Purpose (continued)
In SQL, it is often desirable to be able to restrict the rows
returned by a query based on two or more conditions.
As the business manager of Global Fast Foods, you may
need to know the names of your staff who are either cooks or
order takers. You don't need or want the entire staff list, you
just want a subset of it.
Conditional operators such as AND, NOT and OR make
these types of requests easy to do.

Copyright 2010, Oracle. All rights reserved.

Logical Comparisons and Precedence Rules

Tell Me / Show Me
Logical Conditions
Logical conditions combine the result of
two component conditions to produce a
single result based on them. For example,
to attend a rock concert, you need to buy
a ticket AND have transportation to get
there. If both conditions are met, you can
go to the concert.
What if you can't get transportation, can
you go?
sdm_s18_l01_a02

Copyright 2010, Oracle. All rights reserved.

Logical Comparisons and Precedence Rules

Tell Me / Show Me
Logical Conditions (continued)
Another logical condition combines two
component conditions with OR. All employees
will receive a raise either by having a perfect
attendance record OR by meeting their monthly
sales quota. If an employee meets either of
these two conditions, he/she gets a raise. Using
syntax you already know, rewrite the code to
produce the same results.
WHERE cd_id NOT IN (105, 206, 332);
Will a query using this WHERE clause select
cd_id = 206? The NOT operator excludes the
condition from the query result.

Copyright 2010, Oracle. All rights reserved.

Logical Comparisons and Precedence Rules

Tell Me / Show Me
Logical Operators
A logical operator combines the results of two or more
conditions to produce a single result. A row is returned
ONLY IF the overall result of the condition is true.
AND -- Returns TRUE if both conditions are true.
OR -- Returns TRUE if either condition is true.
NOT -- Returns TRUE if the condition is false.

Copyright 2010, Oracle. All rights reserved.

Logical Comparisons and Precedence Rules

Tell Me / Show Me
AND Operator
In the query below, the results returned will
be rows that satisfy BOTH conditions
specified in the WHERE clause.
SELECT id, title, duration,
type_code
FROM
d_songs
WHERE id > 40
AND
type_code = 77;
ID

TITLE

DURATION

TYPE_CODE

47

Hurrah for Today

3 min

77

49

Lets Celebrate

8 min

77

Copyright 2010, Oracle. All rights reserved.

sdm_s18_l01_a03

Logical Comparisons and Precedence Rules

Tell Me / Show Me
OR Operator
If the WHERE clause uses the OR condition, the results
returned from a query will be rows that satisfy either one of
the OR conditions. In other words, all rows returned have
an ID greater than 48 OR they have a type_code equal to
77. Look at the row with Lets Celebrate -- it has both!
SELECT id, title, duration, type_code
FROM
d_songs
WHERE id > 48
OR
type_code = 77; ID TITLE
DURATION

TYPE_CODE

47

Hurray for Today

3 min

77

49

Lets Celebrate

8 min

77

50

All These Years

10 min

88

Copyright 2010, Oracle. All rights reserved.

Logical Comparisons and Precedence Rules

Tell Me / Show Me
NOT Operator
The NOT operator will return rows that do
NOT satisfy the condition in the WHERE
clause.
SELECT title, type_code
FROM
d_songs
WHERE type_code NOT IN 77;
TITLE

TYPE_CODE

Its Finally Over

12

Im Going to Miss My Teacher

12

Meet Me At the Altar

All These Years

88

Copyright 2010, Oracle. All rights reserved.

10

Logical Comparisons and Precedence Rules

Tell Me / Show Me
Rules of Precedence or What Happens First?
Consider the following SELECT statement. In what
order are the expressions evaluated and
calculated?
SELECT last_name||' '||salary*1.05
As "Employee Raise"
FROM employees
WHERE department_id IN(50,80)
AND first_name LIKE 'C%'
OR last_name LIKE '%s%';
Luckily, when things get this complicated, SQL has
a few basic rules that are easy to follow.

Copyright 2010, Oracle. All rights reserved.

11

Logical Comparisons and Precedence Rules

Tell Me / Show Me
Rules of Precedence or What Happens
First? (continued)
Notice that the AND operator is evaluated
before the OR operator.

This means that if either of


the conditions in the AND
statement are not met, then
the OR operator is used to
select the rows.
This is an important concept
to remember.

ORDER

OPERATORS

Arithmetic + - * /

Concatenation ||

Comparison <, <=, >, >=, <>

IS (NOT) NULL, LIKE, (NOT)


IN

(NOT) BETWEEN

NOT

AND

OR

Copyright 2010, Oracle. All rights reserved.

12

Logical Comparisons and Precedence Rules

Tell Me / Show Me
Rules of Precedence or What Happens First?
(Continued)
Review the next two examples. What will be the output of
each query shown? Is the output what you predicted?
SELECT last_name, specialty, auth_expense_amt
FROM
d_partners
WHERE specialty ='All Types'
OR
specialty IS NULL
AND
auth_expense_amt = 300000;

Copyright 2010, Oracle. All rights reserved.

The order of operations is:


1. Specialty IS NULL AND
auth_expense_amt =
300000. Both these
conditions must be met to
be returned.
2. Any instance of specialty
= 'All Types' will be
returned.

13

Logical Comparisons and Precedence Rules

Tell Me / Show Me
Rules of Precedence or What Happens First?
(Continued)
SELECT last_name, specialty, auth_expense_amt
FROM
d_partners
WHERE (specialty ='All Types'
OR
specialty IS NULL)
AND
auth_expense_amt = 300000;

Copyright 2010, Oracle. All rights reserved.

The order of operations is:


1. The values in the
parentheses are selected.
2. All instances of the
values in the parentheses
that also match
auth_expense_amt =
300000 will be returned.

14

Logical Comparisons and Precedence Rules

Summary
Objectives Summarized
In this lesson, you have learned to:
Evaluate logical comparisons to restrict
the rows returned based on two or more
conditions
Apply the rules of precedence to
determine the order in which
expressions are evaluated and
calculated

Copyright 2010, Oracle. All rights reserved.

15

Logical Comparisons and Precedence Rules

Summary
Practice Guide
The link for the lesson practice guide can be
found in the course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

16

Sorting Rows

Copyright 2011, Oracle. All rights reserved.

Sorting Rows

What Will I Learn?


Objectives
In this lesson, you will learn to:
Construct a query to sort a results set in ascending
or descending order
State the order in which expressions are evaluated
and calculated based on the rules of precedence
Construct a query to order a results set using a
column alias
Construct a query to order a results set for single or
multiple columns

Copyright 2010, Oracle. All rights reserved.

Sorting Rows

Why Learn It?


Purpose
By nature, most of us need order in our lives. Imagine if each
time you had dinner, you had to look in every kitchen drawer
or cabinet to find a knife and a fork? Ordering, grouping, and
sorting makes finding things easier.

Biologists group animals in phyla, astronomers order


brightness of stars by magnitude, and programmers organize
Java code in classes. For database design, business
functions are ordered by entities and attributes; in database
information, SQL uses the ORDER BY clause.
Being able to sort results is a convenient feature in SQL and
enables programmers to display information in many different
ways.
Copyright 2010, Oracle. All rights reserved.

Sorting Rows

Tell Me / Show Me
ORDER BY Clause
Information sorted in ascending order is familiar to most
of us. It's what makes looking up a number in a phone
book, finding a word in the dictionary, or locating a house
by its street address relatively easy.
SQL uses the ORDER BY clause following the FROM
clause to order data. The ORDER BY clause can specify
several ways in which to order rows returned in a query.

Copyright 2010, Oracle. All rights reserved.

Sorting Rows

Tell Me / Show Me
ORDER BY Clause (continued)
The following DJs on Demand example uses
the ORDER BY clause to order the years in
ascending (default) order. Note: The ORDER
BY clause must be the last clause of the SQL
statement.
SELECT title, year
FROM d_cds
ORDER BY year;

TITLE

YEAR

The Celebrants Live in Concert

1997

Graduation Songbook

1998

Songs from My Childhood

1999

Carpe Diem

2000

Party Music for All Occasions

2000

Here Comes the Bride

2001

Back to the Shire

2002

Whirled Peas

2004

Copyright 2010, Oracle. All rights reserved.

Sorting Rows

Tell Me / Show Me
ORDER BY Clause (continued)
The default sort order is ascending.
Numeric values are displayed lowest to highest.
Date values are displayed with the earliest value
first.
Character values are displayed in alphabetical order.
Null values are displayed last in ascending order and
first in descending order.

Copyright 2010, Oracle. All rights reserved.

Sorting Rows

Tell Me / Show Me
Sorting in Descending Order
You can reverse the default order in the ORDER BY
clause to descending order by specifying the DESC
keyword after the column name in the ORDER BY
clause.
SELECT title, year
FROM d_cds
ORDER BY year DESC;
How would you order the
following dates in
descending order? 22MAY-85, null, 10-JAN-04,
17-NOV-55, 21-DEC-98

TITLE

YEAR

Whirled Peas

2004

Back to the Shire

2002

Here Comes the Bride

2001

Party Music for All Occasions

2000

Carpe Diem

2000

Songs from My Childhood

1999

Graduation Songbook

1998

The Celebrants Live in Concert

1997

Copyright 2010, Oracle. All rights reserved.

Sorting Rows

Tell Me / Show Me
Using Column Aliases
You can order data by using a column alias.
The alias used in the SELECT statement is
added to the ORDER BY clause.
SELECT title, year AS
"Recording Date"
FROM d_cds
ORDER BY "Recording Date";

TITLE

RECORDING
DATE

The Celebrants Live in


Concert

1997

Graduation Songbook

1998

Songs from My Childhood

1999

Carpe Diem

2000

Party Music for All Occasions

2000

Here Comes the Bride

2001

Back to the Shire

2002

Whirled Peas

2004

Copyright 2010, Oracle. All rights reserved.

Sorting Rows

Tell Me / Show Me
Sorting With Other Columns
It is also possible to use the ORDER BY
clause to order output by a column that
is not listed in the SELECT clause. In
the following example, the data is sorted
by the last_name column even though
this column is not listed in the SELECT
statement.
SELECT employee_id,
first_name
FROM employees
WHERE employee_id < 105
ORDER BY last_name;

EMPLOYEE_ID

FIRST_NAME

102

Lex

104

Bruce

103

Alexander

100

Steven

101

Neena

Copyright 2010, Oracle. All rights reserved.

Sorting Rows

Tell Me / Show Me
Order of Execution
The order of execution of a SELECT statement is as
follows:
1. FROM clause: locates the table that contains the data
2. WHERE clause: restricts the rows to be returned
3. SELECT clause: selects from the reduced data set the
columns requested
4. ORDER BY: orders the results set

Copyright 2010, Oracle. All rights reserved.

10

Sorting Rows

Tell Me / Show Me
Sorting With Multiple Columns
It is also possible to sort query results by more than one
column. In fact, there is no limit on how many columns you can
add to the ORDER BY clause.
Sorting results by more than one
column is like first sorting all the
students in the school by class or
grade level and then within each
grade-level group, sorting
students alphabetically by last
name.

TITLE

YEAR

Back to the Shire

2002

Carpe Diem

2000

Graduation Songbook

1998

Here Comes the Bride

2001

Party Music for All Occasions

2000

Songs from My Childhood

1999

The Celebrants Live in Concert

1997

Whirled Peas

2004

SELECT title, year


FROM d_cds
ORDER BY title, year;
Copyright 2010, Oracle. All rights reserved.

11

Sorting Rows

Tell Me / Show Me
Sorting With Multiple Columns (continued)
To create an ORDER BY clause to sort by
multiple columns, specify the columns to be
returned and separate the column names
using commas. If after listing the columns you
want to reverse the order of a column, add
DESC after its name.
SELECT title, year
FROM d_cds
ORDER BY year DESC,title;

TITLE

YEAR

The Celebrants Live in Concert

1997

Graduation Songbook

1998

Songs from My Childhood

1999

Party Music for All Occasions

2000

Carpe Diem

2000

Here Comes the Bride

2001

Back to the Shire

2002

Copyright 2010, Oracle. All rights reserved.

12

Sorting Rows

Summary
Objectives Summarized
In this lesson, you have learned to:
Construct a query to sort a results set in ascending
or descending order
State the order in which expressions are evaluated
and calculated based on the rules of precedence
Construct a query to order a results set using a
column alias
Construct a query to order a results set for single or
multiple columns

Copyright 2010, Oracle. All rights reserved.

13

Sorting Rows

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

14

Introduction to Functions Single Row


Functions

Copyright 2011, Oracle. All rights reserved.

Introduction to Functions Single Row Functions

What Will I Learn?


Objectives
In this lesson, you will learn to:
Identify appropriate applications of single-row
functions in query statements
Classify a function as a single-row or multi-row
function
Differentiate between single-row functions and multirow functions and the results returned by each

Copyright 2010, Oracle. All rights reserved.

Introduction to Functions Single Row Functions

Why Learn It?


Purpose
When you put money in a drink
machine, something happens between
the time the money is deposited and
your favorite drink is dispensed. The
transaction is processed internally by
the machine. Your money is the input
and the drink is the output. The
machine performs a function. The
machine:
Counts your money
Makes sure your selection is
chosen
Returns change, if necessary
Copyright 2010, Oracle. All rights reserved.

sdm_s18_l05_a01

Introduction to Functions Single Row Functions

Why Learn It?


Purpose (continued)
In SQL, there are many types of
functions that are used to transform
input in one form to output in
another form. These functions are
used to manipulate data values.
How could you find out whether the
information in the DJs on Demand
CD titles table is stored in
uppercase or lowercase? Execute
a SELECT statement to look at the
output.
SELECT title
FROM d_cds;
Copyright 2010, Oracle. All rights reserved.

sdm_s18_l05_a02

Introduction to Functions Single Row Functions

Tell Me / Show Me
Functions
Functions are programs that do an action on a value or
column and produce something different as output.
Functions have both input and output. Input into a
function is referred to as an argument.

Input

Function

Output

(Argument)

In the drink machine example, the input is money and


the output is a drink.
Money

Drink Machine

Drink

Copyright 2010, Oracle. All rights reserved.

Introduction to Functions Single Row Functions

Tell Me / Show Me
Functions (continued)
Oracle has two distinct types of functions:
Single-Row
Multiple-Row

Functions

Single-row
functions

Multiple-row
functions

Copyright 2010, Oracle. All rights reserved.

Introduction to Functions Single Row Functions

Tell Me / Show Me
Single-Row Versus Multiple-Row Functions
Single-Row Functions
These functions operate on single rows only and return one result
per row. There are different types of single-row functions including
character, number, date, and conversion functions.

Single-row
functions
Multiple-Row Functions
Functions can manipulate groups of rows to give one result per
group of rows. These functions are known as group functions.

Multiple-row
functions
Copyright 2010, Oracle. All rights reserved.

Introduction to Functions Single Row Functions

Tell Me / Show Me
Single-Row Functions
In SQL, functions are a very
powerful feature. They can be
used to:
Perform calculations
such as rounding
numbers to a specified
decimal place
Modify individual data
items such as converting
character values from
uppercase to lowercase
Manipulate output for
groups of rows by finding
an average or sum for
several rows

CHARACTER

NUMBER

GENERAL

SINGLE-ROW
FUNCTIONS

CONVERSION

Copyright 2010, Oracle. All rights reserved.

DATE

Introduction to Functions Single Row Functions

Tell Me / Show Me
Single-Row Functions
(continued)

Format dates and


numbers for display such
as converting the internal
numeric database date
format to a standard
format
Convert column data
types such as converting
a character string to a
number or date

CHARACTER

NUMBER

GENERAL

SINGLE-ROW
FUNCTIONS

CONVERSION

Copyright 2010, Oracle. All rights reserved.

DATE

Introduction to Functions Single Row Functions

Tell Me / Show Me
Single-Row Functions (continued)
Single-Row Functions accept one or more arguments and will
return a single result per row. So if you apply the single row
function to 12 rows, you will get 12 results out of the single row
function.
In summary, single-row functions do the following:
Manipulate data items
Accept arguments and return one value
Act on each row returned
Return one result per row
Can modify the data type
Can be nested

Copyright 2010, Oracle. All rights reserved.

10

Introduction to Functions Single Row Functions

Tell Me / Show Me
Multiple-Row Functions
Multiple-row functions operate on sets of rows to give one
result per group.

AVG
COUNT
MAX
MIN
SUM

Copyright 2010, Oracle. All rights reserved.

11

Introduction to Functions Single Row Functions

Tell Me / Show Me
Multiple-Row Functions (continued)
Group functions take many rows as input, and return a
single value as output.
SELECT MAX(salary), MIN(salary),
AVG(salary)
FROM employees;
MAX(SALARY)

MIN(SALARY)

AVG(SALARY)

24000

2500

8775

Copyright 2010, Oracle. All rights reserved.

12

Introduction to Functions Single Row Functions

Summary
Objectives Summarized
In this lesson, you have learned to:
Identify appropriate applications of single-row
functions in query statements
Classify a function as a single-row or multi-row
function
Differentiate between single-row functions and multirow functions and the results returned by each

Copyright 2010, Oracle. All rights reserved.

13

Introduction to Functions Single Row Functions

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

14

Oracle Academy
Database Design
Instructor Resource Guide
INSTRUCTOR NOTES
SECTION 17 Logical Comparisons and Precedence Rules Lesson
Slide 1: Logical Comparisons and Precedence Rules
What to Watch For
Students will need practice understanding and using the AND condition. When using
AND, both conditions must be true. If one or both conditions aren't true, the statement is
false and then only the OR condition is used, if present.
Connections
Reinforce the OR condition with an example from data modeling. In the DJs on Demand
data model, the entity EVENT had a relationship with two other entities, PRIVATE
HOME and PUBLIC PLACE. In the ERD, an arc was drawn across the two relationship
lines to signify the OR condition. An EVENT had to be held in either a PRIVATE
HOME or a PUBLIC PLACE.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Why Learn It? (continued)
No instructor notes for this slide
Slide 5: Tell Me / Show Me LOGICAL CONDITIONS
Begin the class with a review question. Write a select statement to find an address in the
DJs on Demand database d_venues table that has the word Primrose in the description.
SELECT address FROM d_venues WHERE address LIKE '%Primrose%'
Slide 6: Tell Me / Show Me LOGICAL CONDITIONS (continued)
WHERE cd_id NOT IN(105, 206, 332);
WHERE cd_id != 105 and cd_id != 206 and cd_id!= 332;
Will a query using this WHERE clause select cd_id = 206? No
Slide 7: Tell Me / Show Me LOGICAL Operators
Logical operators combine the results of two or more conditions to produce a single
result.
Use the following as an example, starting first with just one condition on the WHERE,
then adding the other two one at a time.

Oracle Academy

1
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SELECT job_id, department_id, salary
FROM employees
WHERE department_id > 50
AND salary > 10000
AND job_id NOT LIKE 'SA%;
Slide 8: Tell Me / Show Me AND
It will be necessary to reinforce the AND condition when used with OR. Reinforce the
order of precedence in that AND will be evaluated first. However, if one of the AND
conditions is false, the whole condition is false. In that case, the OR operator is used to
restrict the rows.
Slide 9: Tell Me / Show Me OR
No instructor notes for this slide
Slide 10: Tell Me / Show Me NOT
No instructor notes for this slide
Slide 11: Tell Me / Show Me Rules of Precedence or What Happens First?
No instructor notes for this slide
Slide 12: Tell Me / Show Me Rules of Precedence or What Happens First? (continued)
These rules are very important. Ask students to view the data in the d_partners table or do
a SELECT * from table.
Slide 13: Tell Me / Show Me Rules of Precedence or What Happens First? (continued)
These rules are very important. Ask students to view the data in the d_partners table or do
a SELECT * from table. Ask students to look at the two examples shown. Without
actually querying the table, what output is expected? Accept all answers. Ask students to
do a query using each example. Is the output what they expected? Review the output with
the students.
Slide 14: Summary In this lesson you have learned to:
No instructor notes for this slide
Slide 15: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

2
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 17 Sorting Rows Lesson
Slide 1: Sorting Rows
Connections
Relate the ordering of information to the whole process of designing an ERD. Entities in
an ERD make up the group of information items that are data requirements for a business.
An entity is made up of a group of attributes that are properties of the entity.
Before music was available on compact disks (CDs), most music albums were stored on
8-track tapes or vinyl records. If you bought a music tape and wanted to skip to the third
song, you had to fast-forward the tape through the first two songs before what you were
looking for could be played. The recordings were locked into an order that, many times,
was not very convenient and usually not in the order you wanted to listen to them.
Today's technology has changed all that. The order in which songs are recorded on a CD
is of little significance. With the push of a button, we can play them in any order desired.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
Ask students for other ways in which we order our lives.
Suggested answers: Library books in library, grocery-store shelves, department stores,
parking lots, and file cabinets.
Slide 4: Tell Me / Show Me ORDER BY
To reinforce the difference between ascending (ASC) and descending (DESC), ask
students the following questions:
1. If your last name is Yonkers, are you in the front or back of the line in ASC order?
Back of the line
2. If you wanted to sort your address book in DESC order, what names could appear
before mine? Answers will vary depending on the instructor's last name.
3. Would the student who would be first in line in ASC order please raise your hand?
Answers will vary depending on the class list of names.
Slide 5: Tell Me / Show Me ORDER BY (continued)
No instructor notes for this slide

Oracle Academy

3
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 6: Tell Me / Show Me ORDER BY (continued)
Dates can be confusing. The earliest dates are displayed first. Use the dates below to
demonstrate that a date in 1985 would be at the top of a list of dates ordered in ascending
order. Null values in ASC order are displayed last.
29-JAN-00
16-NOV-99
24-MAY-99
07-FEB-99
09-JUL-98
24-MAR-98
Place the following dates in descending order: 22-MAY-85, null, 10-JAN-04, 17-NOV55, 21-DEC-98
Answer: null, 10-JAN-04, 21-DEC-98, 22-MAY-85, 17-NOV-55
Slide 7: Tell Me / Show Me Sorting in Descending Order
No instructor notes for this slide
Slide 8: Tell Me / Show Me Using Column Aliases
Explain the query execution order. Ask students to have a mental picture of being able to
walk into a database to find information just like finding a book in a library.
SELECT employee_id, first_name FROM employees
WHERE employee_id < 105 ORDER BY last_name;
Explain to students that its difficult to verify your results when you sort by a column that
youre not SELECTing. In the real world, you would run your query selecting the
last_name column until you were sure you were getting the right data. Then you could
remove that column from your SELECT statement.
Slide 9: Tell Me / Show Me Sorting with Other Columns
No instructor notes for this slide
Slide 10: Tell Me / Show Me Order of Execution
No instructor notes for this slide
Slide 11: Tell Me / Show Me Sorting with Multiple Columns
No instructor notes for this slide
Slide 12: Tell Me / Show Me Sorting with Multiple Columns (continued)
No instructor notes for this slide
Slide 13: Summary In this lesson you have learned to:
No instructor notes for this slide

Oracle Academy

4
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 14: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

5
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 17 Introduction to Functions Single Row Functions Lesson
Slide 1: Introduction to Functions Single Row Functions
What to Watch For
You can't assign too much practice with functions! The next sections present them in
depth.
Connections
Ask students who have used a library computer system to search for a specific book, if
they had to enter the book title/author or subject in uppercase or lowercase? Did it matter
what case the query was entered in? Most likely the computer program had built-in
functions to handle this situation. Having functions built into programs makes data
retrieval seamless for the user.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Why Learn It? (continued)
Help students organize the SQL syntax for each of the five groups of single-row
functions.
Use the single-row functions graphic each time a new group is introduced.
Slide 5: Tell Me / Show Me FUNCTIONS
No instructor notes for this slide
Slide 6: Tell Me / Show Me FUNCTIONS (continued)
No instructor notes for this slide
Slide 7: Tell Me / Show Me SINGLE-Row Versus Multiple-Row Functions
No instructor notes for this slide
Slide 8: Tell Me / Show Me SINGLE-Row Functions
In SQL, functions are a very powerful feature.
Learning the many different functions can be a challenge for students. Focus on helping
students see the big picture of the different categories of functions and the syntax for each
type. If possible, copy for students the list of functions (link to it). It will help them
organize the information in this and subsequent sections about functions.
Students could make posters that summarize the different groups of functions. It may also
help them organize the information. Display the Single-Row Functions graphic each time
you teach a new function group.
Oracle Academy

6
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 9: Tell Me / Show Me SINGLE-ROW FUNCTIONS (continued)
Read and discuss what functions are capable of accomplishing. Give examples for each
and ask What advantages do these capabilities offer businesses? Look for answers that
Include:
Readability (you can store the date with date, hours, minutes, and seconds, but the
user may only care about day, month, and year);
Formatting (numbers in the data base, such as salary data, lack formatting. The
user, however, may require numeric data displayed as $ for United States dollars
or for British pounds);
Ease of use in data entry (dates entered as Month dd, RRRR are converted to the
default format using date conversions).
Slide 10: Tell Me / Show Me SINGLE ROW FUNCTIONS (continued)
Single-row functions are used to manipulate data items. They accept one or more
arguments and return one value for each row returned by the query. An argument can be
one of the following:
User-supplied constant
Variable value
Column name
Expression
Features of single-row functions include:
Acting on each row returned in the query
Returning one result per row
Possibly returning a data value of a different type than that referenced
Possibly expecting one or more arguments
Can be used in SELECT, WHERE, and ORDER BY clauses; can be nested
Slide 11: Tell Me / Show Me MULTPLE-ROW FUNCTIONS
Unlike single-row functions, group functions operate on sets of rows to give one result
per group. These sets may be the whole table or the table split into groups. The program
behind the AVG function for instance, will sum all the values selected, and divide by the
number of rows selected. Just like you would do an average in the real world. The MAX
function will return the highest value, the MIN the lowest value and so on and so forth.
Slide 12: Tell Me / Show Me MULTIPLE-ROW FUNCTIONS (continued)
You can use AVG, SUM, MIN, and MAX functions against columns that can store
numeric data. The example on the slide displays the average, highest, lowest salary for all
employees.
Slide 13: Summary In this lesson you have learned to:
No instructor notes for this slide

Oracle Academy

7
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 14: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

8
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
PRACTICE SOLUTIONS
SECTION 17 Logical Comparisons and Precedence Rules Lesson
Vocabulary
NOT

Inverts the value of the condition

AND

Both conditions must be true for a record to be


selected

Precedence

Rules that determine the order expressions are


evaluated and calculated

OR

Either condition can be true for a record to be


selected

Try It / Solve It
1. Execute the two queries below. Why do these nearly identical statements produce two
different results? Name the difference and explain why.
SELECT code, description
FROM d_themes
WHERE code >200 AND description IN('Tropical', 'Football', 'Carnival');
SELECT code, description
FROM d_themes
WHERE code >200 OR description IN('Tropical', 'Football', 'Carnival');
Solution:
The AND condition must satisfy both code and description to return a value. The OR
condition will return values that satisfy either condition.SELECT DISTINCT
last_name, address,city, state, zip FROM f_customers;
2. Display the last names of all Global Fast Foods employees who have e and i in
their last names.
Solution:
SELECT last_name
FROM f_staffs
WHERE last_name LIKE '%e%' AND last_name LIKE '%i%';
Oracle Academy

9
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
3. I need to know who the Global Fast Foods employees are that make more than
$6.50/hour and their position is not order taker.
Solution:
SELECT last_name
FROM f_staffs
WHERE salary > 6.50 AND staff_type!= 'Order Taker';
4. Using the employees table, write a query to display all employees whose last names
start with D and have a and e anywhere in their last name.
Solution:
SELECT last_name
FROM employees
WHERE last_name LIKE 'D%a%e%' or last_name LIKE 'D%e%a';
5. In which venues did DJs on Demand have events that were not in private homes?
Solution:
SELECT loc_type
FROM d_venues
WHERE loc_type NOT IN('Private Home');
6. Which list of operators is in the correct order from highest precedence to lowest
precedence?
a. AND, NOT, OR
b. NOT, OR, AND
c. NOT, AND, OR
Solution:
c. NOT, AND, OR

Oracle Academy

10
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
For questions 7 and 8, write SQL statements that will produce the desired output.
7. Who am I?
I was hired by Oracle after May 1998 but before June of 1999. My salary is less than
$8000 a year and I have an en in my last name.
Solution:
SELECT first_name, last_name
FROM employees
WHERE last_name LIKE '%en%' and salary < 8000 and hire_date BETWEEN '01JUN-98' AND '31-MAY-99';
Diana Lorentz
8. What's my email address?
Because I have been working for Oracle since the beginning of 1996, I make more
than $9000 per month. Because I make so much money, I don't get a commission
Solution:
SELECT email
FROM employees
WHERE hire_date BETWEEN '01-JAN-96' AND '31-DEC-96' AND salary > 9000
AND commission_pct IS NULL;
MHARTSTE
An alternative solution for #8 is:
SELECT email
FROM employees
WHERE hire_date > '01-JAN-96' AND salary > 9000
AND commission_pct IS NULL ;

Oracle Academy

11
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 17 Sorting Rows Lesson
Vocabulary
Ascending/ ASC

Orders the rows in ascending order (the default


order); A-Z

Descending/ DESC

Orders the rows in descending order: Z-A

Sort

To arrange according to class, kind, or size

Try It / Solve It
1. In the example below, assign the employee_id column the alias of Number.
Complete the SQL statement to order the results set by the column alias.
SELECT employee_id, first_name, last_name
FROM employees;
Solution:
SELECT employee_id AS "Number", first_name, last_name
FROM employees
ORDER BY "Number";
2. Create a query that will return all the DJ on Demand CD titles ordered by year with
titles in alphabetical order by year.
Solution:
SELECT title, year
FROM d_cds
ORDER BY year, title;
3. Order the DJ on Demand songs by descending title. Use the alias "Our Collection" for
the song title.
Solution:
SELECT title AS "Our Collection"
FROM d_songs
ORDER BY title DESC;

Oracle Academy

12
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
4. Order the DJ on Demand songs by descending title. Use the alias "Our Collection" for
the song title.
Solution:
SELECT first_name, last_name, student_id, year_in_school, parking_space
FROM students
WHERE year_in_school = 1
ORDER BY last_name, first_name DESC;
(exact syntax names will vary)
5. Write a SQL statement using the employees table and the ORDER BY clause that
could retrieve the information in the following table. Return only those employees
with employee_id<125.
DEPARTMENT_ID LAST_NAME MANAGER_ID
90
Kochhar
100
90
King
(null)
90
De Haan
100
60
Lorentz
103
60
Hunold
102
60
Ernst
103
50
Mourgos
100
Solution:
SELECT department_id, last_name, manager_id
FROM employees
WHERE employee_id < 125
ORDER BY department_id desc, last_name desc, manager_id desc

Oracle Academy

13
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Extension Activities
1. Limiting values with the WHERE clause is an example of:
a. Projection
b. Ordering
c. Joining
d. Grouping
e. Selection
Solution:
e. Selection
2. You want to sort your CD collection by title, and then by artist. This can be
accomplished using:
a. WHERE
b. SELECT
c. ORDER BY
d. DISTINCT
Solution:
c. ORDER BY
3. Which of the following are SQL keywords?
a. SELECT
b. ALIAS
c. COLUMN
d. FROM
Solution:
a. SELECT
d. FROM
4. Which of the following are true?
a. Multiplication and division take priority over addition.
b. Operators of the same priority are evaluated from left to right.
c. Parentheses can be used to override the rules of precedence.
d. None of the above are true.
Solution:
a, b, and c are true

Oracle Academy

14
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
5. The following query was written:
SELECT DISTINCT last_name
FROM students
a.
b.
c.
d.

To select all the outstanding students


To choose last names that are duplicates
To select last names without duplicates
To select all last names

Solution:
c. To select last_names without duplicates
6. The following string was created using which SELECT clause?
Abby Rogers is an order taker for Global Fast Foods
a. SELECT first_name ||' ' ||last_name ||' is an ' staff_type ' for Global Fast Foods'
b. SELECT Abby Rogers is an ||staff_type||' for Global Fast Foods'
c. SELECT first_name,last_name '||staff_type||' for Global Fast Foods'
d. SELECT first_name ||' ' ||last_name ||' is an '||staff_type||' for Global Fast Foods'
Solution:
d. SELECT first_name ||' ' ||last_name ||' is an '||staff_type||' for Global Fast Foods'
7. Which of the following SELECT clauses will return uppercase column headings?
a. SELECT id, last_name, address, city, state, zip, phone_number;
b. SELECT ID, LAST_NAME, ADDRESS, CITY, STATE, ZIP,
PHONE_NUMBER;
c. SELECT Id, Last_name, Address, City, State, Zip, Phone_number;
d. SELECT id AS ID, last_name AS NAME, address AS ADDRESS, city AS CITY,
state AS STATE, zip AS ZIP, phone_number AS PHONE_NUMBER;
Solution:
All of the above will return uppercase column headings by default
8. Which SELECT clause will return the last names in alphabetical order?
a. SELECT last_name AS ALPHABETICAL
b. SELECT last_name AS ORDER BY
c. SELECT last_name
d. SELECT ASC last_name
Solution:
a,b,c will return last names in alphabetical order

Oracle Academy

15
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
9. Which SELECT clause will return a column heading for employee_id called New
Employees?
a. SELECT last_name AS "New Employees"
b. SELECT employee_id AS New Employees
c. SELECT employee AS "New Employees"
d. SELECT employee_id AS "New Employees"
Solution:
d. SELECT employee_id AS "New Employees"
10. Examine the following query:
SELECT last_name, job_id, salary
FROM employees
WHERE job_id = 'SA_REP' OR job_id = 'AD-PRES' AND salary >15000;
Which results could not have been returned from this query?
a.
b.
c.
d.

Joe Everyone, sales representative, salary 15000


Jane Hendricks, sales manager, salary 15500
Arnie Smithers, administration president, 20000
Jordan Lim, sales representative, salary 14000

Solution:
c. Arnie Smithers, administration president, 20000
11. Finish this query so it returns all employees whose last names start with St.
SELECT last_name
FROM employees
Solution:
WHERE last_name LIKE 'St%';
12. What salary values will not be returned from this query?
SELECT last_name, first_name, salary
FROM employees
WHERE salary BETWEEN 1900 AND 2100;
Solution:
Values less than or equal to 1900 or greater than or equal to 2100 will be included in
the result set.

Oracle Academy

16
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
13. Correct each WHERE clause:
a. WHERE department_id NOT IN 101,102,103;
b. WHERE last_name = King
c. WHERE start date LIKE "05-MAY-98"
d. WHERE salary IS BETWEEN 5000 AND 7000
e. WHERE id =! 10
Solution:
a. WHERE department_id NOT IN (101,102,103);
b. WHERE last_name = 'King'
c. WHERE start_date LIKE '05-MAY-98'
d. WHERE salary BETWEEN 5000 AND 7000
e. WHERE id != 10
14. SELECT prefix
FROM phone
WHERE prefix BETWEEN 360 AND 425
OR prefix IN (206, 253,625)
AND prefix BETWEEN 315 AND 620;
Which of the following values could be returned?
625, 902, 410, 499
Solution:
410

Oracle Academy

17
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 17 Introduction to Functions Single Row Functions Lesson
Try It / Solve It
1. For each task, choose whether a single-row or multiple row function would be most
appropriate:
a.
b.
c.
d.

Showing all of the email addresses in upper case letters


Determining the average salary for the employees in the sales department
Showing hire dates with months spelled out (September 1, 2004)
Finding out the employees in each department that had the most seniority (the
earliest hire date)
e. Displaying the employees salaries rounded to the hundreds place
f. Substituting zeros for null values when displaying employee commissions.
Solution:
a. single b. multiple c. single d. multiple e. single f. single

2. The most common multiple-row functions are: AVG, COUNT, MAX, MIN, and
SUM. Give your own definition for each of these functions.
Solution:
AVG calculates and returns the average value from a set of numeric values
COUNT counts and returns the number of non null values from a set of values
MAX returns the highest value from a set of values (most recent date, highest
number, or last alphabetically sorted text value)
MIN returns the lowest value from a set of values (oldest date, lowest number, or
first alphabetically sorted text value)
SUM returns the sum of a set of numeric values

Oracle Academy

18
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
3. Test your definitions by substituting each of the multiple-row functions in this query.
SELECT FUNCTION(salary)
FROM employees
Write out each query and its results.
Solution:
SELECT AVG(salary)
FROM employees ;

RESULT
8775

SELECT COUNT(salary)
FROM employees ;

20

SELECT MAX(salary)
FROM employees ;

24000

SELECT MIN(salary)
FROM employees ;

2500

SELECT SUM(salary)
FROM employees ;

175500

Oracle Academy

19
Database Design
Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

What Will I Learn?


Objectives
In this lesson, you will learn to:
Describe the importance of describing information
requirements
Distinguish between a conceptual model and the
physical implementation
List five reasons for building a conceptual data model
List examples of conceptual models and physical
models

Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

Why Learn It?


Purpose
When you are able to recognize and analyze information, you can
better understand how things work and potentially make them better.
For example:
How to make the line at the food counter go faster
How to make a successful exchange at the store
How to organize and keep track of your growing CD collection
Also, recognizing and analyzing information helps prevent mistakes
and misunderstanding. For a business, this is important because it
saves time and money.

Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

Tell Me / Show Me
Animation
View the following animation and participate in
the discussion afterward.
Was this an easy way to get an order of
sandwiches?

sdm_s02_l01_a01

What would you have done differently if you were


the chef?
What would you have done differently if you were
the one placing the order?

Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

Tell Me / Show Me
Comparing Conceptual and Physical
Models
sdm_s02_l01_a02
What the person had in mind was the
conceptual model, and what the chef created
was the physical model of the sandwich tray.
It would have helped if the conceptual model
was understood by both from the beginning.
Can you think of other examples where
accurately describing what you want
(conceptual) is important in getting what you
want (physical)?

Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

Tell Me / Show Me
What is a Conceptual Model?
Models functional and informational needs
sdm_s02_l01_a03
of a business
Based on current needs and may reflect
future needs
Deals only with business needs, does not
deal with implementation problems
Called an Entity Relationship Model
Shown with an Entity Relationship
Diagram

Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

Tell Me / Show Me
What is a Conceptual Model (continued)
Businesses use data to increase sales and/or reduce costs. In the
process of creating a data model a business will create a
conceptual model of their data. The purposes of a conceptual model
are to:
Describe exactly the information needs of the business
Facilitate discussion
Prevent mistakes, misunderstandings
Form important ideal system documentation
Form a sound basis for physical database design
Document the processes of the business (this is also known as
the business rules)
Take into account regulations and laws governing this industry

Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

Tell Me / Show Me
Conceptual and Physical Models
Its the art of planning, developing, and communicating that
produces a desired outcome.
Data modeling involves getting the requirements down and
using a diagram to describe them. This diagram becomes
the blueprint for designing the actual thing.

The clients dream (conceptual model) will become a


physical building (physical model).

Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Conceptual model
Data
Data model
Physical model

Copyright 2011, Oracle. All rights reserved.

Conceptual and Physical Models

Summary
Objectives Summarized
In this lesson, you have learned to:
Describe the importance of describing information
requirements
Distinguish between a conceptual model and the
physical implementation
List five reasons for building a conceptual data model
List examples of conceptual models and physical
models

Copyright 2011, Oracle. All rights reserved.

10

Conceptual and Physical Models

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

11

Entities, Instances, Attributes and


Identifiers

Copyright 2011, Oracle. All rights reserved.

Entities, Instances, Attributes and Identifiers

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define and give an example of an entity
Distinguish between an entity and an instance of an entity
Name and describe attributes for a given entity
Distinguish between an attribute and its value
Distinguish between mandatory and optional attributes,
and between volatile and nonvolatile attributes
Select and justify a unique identifier (UID) for an entity

Copyright 2011, Oracle. All rights reserved.

Entities, Instances, Attributes and Identifiers

Why Learn It?


Purpose
Knowing how to organize and classify data makes it
possible to draw useful conclusions about seemingly
random facts. Our technology-rich world produces vast
quantities of facts in need of structure and order.
It is important to learn about entities because they are the
things about which we store data.
For example:
A school needs to store data about (as a minimum):
STUDENTs, TEACHERs, COURSEs, ROOMs, GRADEs.

Copyright 2011, Oracle. All rights reserved.

Entities, Instances, Attributes and Identifiers

Why Learn It?


Purpose (continued)
It is important to learn about attributes
because they provide more information about
the entities.

Attributes help you be more specific about


what data you need to track.
For example:
In a restaurant, you need to list the different items in an
order so you know how much to charge.
When building several sales reports for a department, you
must pick out the correct sales report from a list of reports.
Copyright 2011, Oracle. All rights reserved.

Entities, Instances, Attributes and Identifiers

Why Learn It?


Purpose (continued)
What about unique identifiers? It is important to learn about
unique identifiers because they distinguish one instance of an
entity from another.

For example:
In a classroom, you need to distinguish between one
person and another.
When classifying your CD collection, you need to be able
to locate a particular CD.
When listing transactions on a financial statement you
need to be able to distinguish between multiple
transactions that occurred on the same day.
Copyright 2011, Oracle. All rights reserved.

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Identifying Purpose
Look at the magazine
advertisements and the
Internet sites identified by
the teacher.
What is the main thing
that each ad or website is
about?

Copyright 2011, Oracle. All rights reserved.

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Entity Defined
An entity is:
Something of significance
to the business about which
data must be known
A name for a set of similar
things that you can list
Usually a noun
Examples: objects, events,
people
Entities have instances. An
instance is a single occurrence
of an entity.
Copyright 2011, Oracle. All rights reserved.

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Entities and Instances

CAR
Entities
PERSON
PRODUCT
PRODUCT TYPE
JOB
SKILL LEVEL
CONCERT
ANIMAL
CAR

ANIMAL

Instances
Mahatma Gandhi
Nike Air Jordan
shoe
electrician
beginner
U2 at the Palladium
Dog
Volkswagen beetle

Copyright 2011, Oracle. All rights reserved.

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Entities and Instances (continued)
A Dalmatian, a Siamese cat, a cow and a
pig are instances of ANIMAL
A convertible, a sedan and a station
wagon are instances of CAR
There are many entities
Some entities have many instances;
some have only a few
Entities can be:
Tangible, like PERSON or PRODUCT
Intangible, like SKILL LEVEL
An event, like CONCERT

Copyright 2011, Oracle. All rights reserved.

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Entities and Instances (continued)
Is DOG an instance or an entity? It depends:
If we are interested in different kinds of
animals, it makes sense to think of an
entity ANIMAL with instances DOG, CAT,
HORSE and so on
But what if we run a dog-breeding business? We need
to keep data on many different breeds of dog, but not on
other species of animal.
For a dog-breeder, it is more natural to think of an entity
DOG with instances TERRIER, POODLE, LABRADOR
and so on.

Copyright 2011, Oracle. All rights reserved.

10

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
What is an attribute?
Like an entity, an attribute
represents something of
significance to the business.
An attribute is a specific piece of
information that:

Describes an entity

Quantifies an entity

Qualifies an entity

Classifies an entity

Specifies an entity

What is an
Attribute?

sdm_s02_l03_a02

An attribute has a single value.


Copyright 2011, Oracle. All rights reserved.

11

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Attributes
ENTITIES

ATTRIBUTES

CUSTOMER

family name, age, shoe size,


town of residence, email

CAR

model, weight, catalog price

ORDER

order date, ship date

JOB

title, description

TRANSACTION

amount, transaction date

EMPLOYMENT
CONTRACT

start date, salary

Attributes have values. An attribute value can be a


number, a character string, a date, an image, a sound,
etc. These are called "data types" or "formats." Every
attribute has a data type.

Copyright 2011, Oracle. All rights reserved.

12

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Attributes (continued)
ENTITIES

ATTRIBUTES

CUSTOMER

family name, age, shoe size,


town of residence, email

CAR

model, weight, catalog price

ORDER

order date, ship date

JOB

title, description

TRANSACTION

amount, transaction date

EMPLOYMENT
CONTRACT

start date, salary

What would be the data types of the CUSTOMER attributes?


For example, family name would be a character string.
Attributes are single-valued. Each attribute can have only one
value (at any point in time) for each instance of the entity.
Copyright 2011, Oracle. All rights reserved.

13

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Attributes (continued)
ENTITIES

ATTRIBUTES

CUSTOMER

family name, age, shoe size,


town of residence, email

CAR

model, weight, catalog price

ORDER

order date, ship date

JOB

title, description

TRANSACTION

amount, transaction date

EMPLOYMENT
CONTRACT

start date, salary

Some attributes (such as age) have values that constantly change.


These are called volatile attributes.
Other attributes (such as order date) will change rarely, if ever.
These are nonvolatile attributes.
If there is a choice between attributes, use the nonvolatile one. For
example, use birth date instead of age.
Copyright 2011, Oracle. All rights reserved.

14

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Attributes (continued)
Some attributes must have a value. These are mandatory
attributes. For example: in most businesses that track
personal information, name is required.
Others attributes may have a value or be left null. These are
optional attributes. For example: cell phone number is often
not required, except in mobile or wireless applications.

Email address could be a mandatory attribute for EMPLOYEE


if you are modeling an email application. It could be optional
for a CUSTOMER if you are modeling an online catalog.

Copyright 2011, Oracle. All rights reserved.

15

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Attributes (continued)
A disc jockey (DJ) has to be familiar
with all kinds of music -- songs,
soundtracks, etc. If we were to model a
DJ business, the entity that holds the
collection of music could be called
SONG.

sdm_s02_l03_a03

A SONG has attributes.


What attributes would it have?
Can you give examples of values for
each attribute?

Copyright 2011, Oracle. All rights reserved.

16

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Identifiers
A SONG has a unique identifier (UID).

sdm_s02_l03_a04

A UID is an attribute or combination of attributes that


distinguish one song from another.
How do you find a particular song in the whole
collection? What would be a unique identifier for
SONG?
Think about all the students in the classroom. Each
student is described by several traits or attributes.
Which attribute or attributes allow you to pick a single
student from the rest of the class?

That is the students UID.


Copyright 2011, Oracle. All rights reserved.

17

Entities, Instances, Attributes and Identifiers

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Attribute
Data type
Entity
Instance
Mandatory
Intangible
Null
Optional
Single valued
Tangible
Unique identifier (UID)
Volatile
Copyright 2011, Oracle. All rights reserved.

18

Entities, Instances, Attributes and Identifiers

Summary
Objectives Summarized
In this lesson, you have learned to:
Define and give an example of an entity
Distinguish between an entity and an instance of an entity
Name and describe attributes for a given entity
Distinguish between an attribute and its value
Distinguish between mandatory and optional attributes,
and between volatile and nonvolatile attributes
Select and justify a unique identifier (UID) for an entity

Copyright 2011, Oracle. All rights reserved.

19

Entities, Instances, Attributes and Identifiers

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

20

Entity Relationship Modeling and ERDs

Copyright 2011, Oracle. All rights reserved.

Entity Relationship Modeling and ERDs

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define the meaning of implementation-free as it relates
to data models and database design implementation
List the four goals of entity relationship modeling
Identify an entity relationship diagram (ERD)

Copyright 2011, Oracle. All rights reserved.

Entity Relationship Modeling and ERDs

Why Learn It?


Purpose
An entity relationship diagram, abbreviated as ERD, is a
consistent tool that can be used to represent data
requirements regardless of what type of database is used,
or even if a database is not used at all!

Copyright 2011, Oracle. All rights reserved.

Entity Relationship Modeling and ERDs

Tell Me / Show Me
Implementation-Free Models
A good conceptual data model
stays the same regardless of
what type of database the
system is eventually built on.
This is what we mean when we
say that the model is
implementation-free.
The data model should stay the
same even if a database is not
used at all (ex. data is eventually
stored on pieces of paper in a
filing cabinet).

Database Types
ER Model

Hierarchical
Database

Copyright 2011, Oracle. All rights reserved.

Network
Database
Relational
Database

Entity Relationship Modeling and ERDs

Tell Me / Show Me
What is an Entity Relationship Model?
A list of all entities and attributes as well
as all relationships between the entities
that are of importance
Provides background information such
as entity descriptions, data types and
constraints
Note: The model does not necessarily
include a diagram, but typically the
diagram is very useful

Copyright 2011, Oracle. All rights reserved.

Entity Relationship Modeling and ERDs

Tell Me / Show Me
Goals of ER Modeling
There are four goals of ER modeling:
Capture all required information
Ensure that information appears only once
Model no information that is derivable from
other information already modeled
Locate information in a predictable, logical
place

sdm_s02_l04_a02

Think of your school record. From your first days


in school, data about you was captured. There is
probably a record of your absences, notes on
discipline, classes taken, and grades earned.

Copyright 2011, Oracle. All rights reserved.

Entity Relationship Modeling and ERDs

Tell Me / Show Me
DJs on Demand Business Scenario
Read the complete business scenario for the DJ business
below. Then examine the completed ERD.
We started out as a group of friends who organized parties
and customized our own music. Then we thought wed turn
it into a business to pursue our interests and earn some
money. We called ourselves the DJs on Demand.

Everyone who works here is a partner. Every partner has a


specific responsibility. The project manager makes the first
contact with the client to discuss the event. Is it a birthday
party, a wedding, an anniversary, a graduation? What is
the date for the party or event?
Copyright 2011, Oracle. All rights reserved.

Entity Relationship Modeling and ERDs

Tell Me / Show Me
DJs on Demand Business Scenario (continued)
Once thats decided, the event planner gets in touch with the client
about specific locations, catering, decorations, and other specific
details. The DJ talks with the client about the kind of music wanted.
The project manager supervises the event planners and DJs. He/she
also authorizes expenditures related to a project.
We have a large collection of CDs. Each CD contains several songs,
and the same song can appear on several CDs. We like to classify
each song by type (hip hop, salsa, R & B (rhythm and blues), techno,
salsa, polka, rock, jazz, new age, classical, etc.)
We can propose an initial list of songs to the client depending on the
event. Of course, a client can request other songs as well.

Copyright 2011, Oracle. All rights reserved.

Entity Relationship Modeling and ERDs

Tell Me / Show Me
DJs on Demand Business Scenario (continued)
Our client list is growing. We have a lot of repeat business -customers who like what weve done and ask us to work their
other events. We have some very busy customers who can
have more than one event going on at the same time.

We also have a list of themes that we can use to categorize


these events. For example: a wedding may have a tropical
theme, a party may have a carnival theme, an anniversary
could have a sixties theme, etc. This helps us pick a venue and
also gives us an idea of what the DJ (and other musicians)
should wear. Some partners have a specialty or expertise -- so
a theme also can help us assign the right person to the job.

Copyright 2011, Oracle. All rights reserved.

Entity Relationship Modeling and ERDs

Tell Me / Show Me
DJs on Demand Business Scenario
(continued)
Events are held either in a public space
or a private home. The event manager
visits both and makes arrangements
with the public-space renter or the
private-home owner.
Since several partners can work on an
event, and an event can be assigned to
several partners, we like to keep track
of who is working on which event. We
keep a log of what each event planner
and DJ has done on an event, and
when they did it.

Copyright 2011, Oracle. All rights reserved.

10

Entity Relationship Modeling and ERDs

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Implementation-free
Entity relationship diagram (ERD)

Copyright 2011, Oracle. All rights reserved.

11

Entity Relationship Modeling and ERDs

Summary
Objectives Summarized
In this lesson, you have learned how to:
Define the meaning of implementation-free as it relates
to data models and database design implementation
List the four goals of entity relationship modeling
Identify an entity relationship diagram (ERD)

Copyright 2011, Oracle. All rights reserved.

12

Entity Relationship Modeling and ERDs

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

13

Oracle Academy
Database Design
Instructor Resource Guide
INSTRUCTOR NOTES
SECTION 2 Conceptual and Physical Models Lesson
Slide 1: Conceptual and Physical Models
Lesson Preparation
This lesson begins the actual data-modeling content. Before jumping into definitions of
attributes and entities, we first want students to understand the concept of modeling and
to recognize models conceptual vs. physical. This lesson provides reasons for creating a
data model in the first place, as opposed to just going ahead and building a database.
You may want to ask students, Have you ever had trouble finding a document in a filing
cabinet or folder that someone else organized? The files may have been organized to
meet their needs, but not your own.
Data modeling attempts to capture the needs of the business users so that the resulting
database is one that everyone can use easily.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn it?
Ask: If you were the manager of a fast-food restaurant, why would you want to collect
information about how to make the customer lines at the food counter go faster?
Discuss who benefits from this.
Answers include:
The faster you can serve people, the greater the profits are for your store!
What would be the profits of [USE THE NAME OF A POPULAR RESTAURANT IN
YOUR AREA] if they could only serve one customer per hour?
Businesses benefit, as well as the customer. You would not return to a restaurant that
could serve only one person per hour, would you?
Slide 4: Tell Me / Show Me View the following animation
Play the animation and then ask the class:
What is the problem in this animation?
What could have been done to make this easier?
Who should do things differently, the chef or the customer?
Feel free to replay and pause the animation if it helps the class discussion.

Oracle Academy

1
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Key responses would include:
The chef should have asked more questions before preparing the sandwiches
because he is the one who needs to do all of the work!
The woman should have a better-defined order.
Slide 5: Tell Me / Show Me What the person had in mind was the
Conceptual model: A data model, usually represented by an entity-relationship diagram
Physical model: A design for an object (a car, a house, a database, etc.) which includes
implementation details such as size, volume, weight, etc.)
You can explain the graphics if necessary:
In the first one, the boy is thinking of getting a nice sports car but is given a
practical car instead.
In the second one, the girl is expecting a big bouquet of flowers but gets
something considerably smaller.
Slide 6: Tell Me / Show Me What is a Conceptual Model?
Data: A collection of facts from which conclusions may be drawn
Data model: The product of the database design process which aims to identify and
organize the required data
This animation is similar to the one at the beginning of the lesson, but this time, the
customer specifies what she wants from the start. The chef is able to execute the order
perfectly. No time is wasted and everyone is happy. You may want to ask students how
the same result could be achieved.
Answer: The chef could have questioned the customer until he knew exactly what she
wanted. If there was an employee manual specifying how to take an order, there would
have been a complete order given to the chef by an order taker.
Slide 7: Tell Me / Show Me What is a Conceptual Model (continued)
No instructor notes for this slide
Slide 8: Tell Me / Show Me Conceptual and Physical Models
No instructor notes for this slide
Slide 9: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 10: Summary In this lesson you have learned how to:
No instructor notes for this slide
Slide 11: Summary Practice Guide
No instructor notes for this slide
Oracle Academy

2
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 2 - Entities, Instances, Attributes and Identifiers Lesson
Slide 1: Entities, Instances, Attributes and Identifiers
Lesson Preparation
In this lesson, we will start discussing the data model for a DJ (Disc Jockey) business.
This is an example business scenario and model that will recur throughout the content.
This consistent topic will help the students to learn data-modeling concepts.
No diagram will be shown in this lesson; we just want the students to start thinking about
the business.
What to Watch For
Give additional examples of entities (SHOPPING MALL, MOVIE STAR, SHOE) and
ask them to name instances of each.
This will help you determine if they can distinguish between the two.
Make sure they can distinguish between entities and attributes.
Is the attribute single-valued? If not, then its an entity. (Use example of CLASS
and STUDENT, where there are many students in one class.)
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It? Knowing how to organize and classify data
Ask students what kind of information they need to know or work with in each of these
jobs:
IT programmer/consultant
Bank manager
Restaurant cashier
Artist
Parent
Slide 4: Why Learn It? It is important to learn about attributes because
No instructor notes for this slide
Slide 5: Why Learn It? What about unique identifiers?
Instance: An occurrence or example.
Slide 6: Tell Me / Show Me Look at the magazine advertisements
Pass magazine ads around the class and/or look at commercial websites.
Some suggestions are:
http://www.nike.com - sports equipment
http://www.weyl.com - beef industry
en-tranz.com - entertainment
http://carmax.com - used cars
Oracle Academy
3
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide

http://www.hallmark.com - greeting cards


http://www.sephora.com - beauty products
http://telstra.com - communication
http://changan.com - automobiles

Ask students to identify the main thing about the ads or sites. They will usually come
up with a list of entities and instances. Define entities and distinguish them from
instances with examples. For example, if you use the Nike website/business with your
class, make sure that they see the difference between the entity FOOTWEAR and the
instance of the entity as Nike Shoe (or other shoe style).
Slide 7: Tell Me / Show Me An entity is:
Entity: A named thing or category of things that is significant to the business and about which
data must be known

Slide 8: Tell Me / Show Me Entities and Instances


Example: The Entity FRUIT has instances of orange, apple, peach, kiwi, cherry, lime,
lemon
Slide 9: Tell Me / Show Me Entities and Instances (continued)
Nontangible: Incapable of being perceived by the senses.
Tangible: Perceptible by the senses, especially the sense of touch
Slide 10: Tell Me / Show Me Entities and Instances (continued)
It would not make sense to have an entity with only one instance. Ask students to think
of other examples of it depends.
Slide 11: Tell Me / Show Me What is an attribute?
Attribute: Characteristic, something that describes, quantifies or specifies an entity
An attribute is a piece of information that in some way describes an entity. An attribute is
a property of the entity, a detail about the entity.
Entities Have Attributes
For now, tell students to assume that all entities have at least one attribute. Later, we will
discover exceptions to this assumption. Usually, there are many attributes for an entity,
but again, we are interested only in those attributes that are of importance to the business.
Example: The Entity FRUIT has attributes of name, type, region, date_picked.
An instance of this would be:
Orange, citrus, west coast, 10-APR-05

Oracle Academy

4
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 12: Tell Me / Show Me Examples of Attributes
Datatype: A classification identifying one of various types of data, stating the possible
values for that type, the operations that can be done on that type, and the way the values
of that type are stored
Single- valued: Can only have one value at any point for each instance in the entity
Slide 13: Tell Me / Show Me Examples of Attributes
Attributes:
Point out that the only attributes they need to model are those that the business wants to
track. So for example, you may want to track shoe size as an attribute of customer if you
are a shoe store, but maybe not if you are a grocery store. It all depends on the business
requirements.
Every attribute has a datatype. For example, the attribute name would be of a datatype
like character string, the attribute salary would have a number datatype, and the
attribute photograph would likely be of an image datatype.
Attribute Is Single-Valued
An attribute for an entity must be single-valued. In more precise terms, an entity instance
can have only one value for that attribute at any point in time. This is the most important
characteristic of an attribute. The attribute value, however, may change over time.
For example: The entity CAR may have attributes model and color. There can be
only one value for these (for example, beetle and green) at one time, for each
instance (i.e. for each individual car). Although model stays constant over the lifetime of
the car, color could change.
Slide 14: Tell Me / Show Me Examples of Attributes
Volatile: Highly changeable
One reason for preferring nonvolatile attributes (if there is a choice) is that volatile
attributes will need to be updated frequently. For example, age must be updated every
year. How long would this take if we had 1 million customers? If we need to know a
customers age, we can easily deduce it from the birth date.
Slide 15: Tell Me / Show Me Some attributes must have a value
Mandatory: Required
Null: A value that is unavailable, unassigned, unknown, or inapplicable; it is not a zero or
space
Optional: Not required
Slide 16: Tell Me / Show Me A disc jockey (DJ) has to
Have students talk about their favorite DJs and what makes them so good. DJs have to
know a lot about music. Talk about the SONG entity, which is the collection of songs
and soundtracks. Ask class to give attributes that describe it and values for each attribute.
Oracle Academy

5
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Possible answers would be title (here they could name their favorite songs), composer,
date released/composed, duration, and artist (this one is potentially multivalued, as
several artists could perform the same song. Provide the business assumption that each
artists version is considered a different performance of that song, and we will define it as
a different instance in the SONG entity. After all, when you request a song, you often
also have a specific artists version in mind).
Then point out attributes that are mandatory (such as a title) and some that are optional
(such as the date it was released). Explain that release date is a better attribute than age
because it is less volatile.
Slide 17: Tell Me / Show Me Identifiers
Unique identifier: Any combination of attributes and/or relationships that serves, in all
cases, to uniquely identify an occurrence of an entity
What combination of traits uniquely identifies a single STUDENT?
Students name? No, there could be two students with the same name.
Date of birth? No, there could be two students born on the same day.
For almost any combination of student attributes, it is at least possible that two students
could have the same combination of values.
This is why for entities such as STUDENT, we create an artificial student number or
student ID.
Ask the class if title would be sufficient to uniquely identify a SONG. Answer: No,
because there are cases of songs with the same title.
Would a combination of attributes work? Probably. (Example: title and composer
and artist.)
Could you decide to just assign a unique ID to each SONG, similar to Student
number? Yes.
Slide 18: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 19: Summary In this lesson you have learned how to:
No instructor notes for this slide
Slide 20: Summary Practice Guide
No instructor notes for this slide
Oracle Academy

6
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 2 Entity Relationship Modeling and ERDs Lesson
Slide 1: Entity Relationship Modeling and ERDs
Lesson Preparation
No further lesson preparation information.
What to Watch For
Make sure that information is stored only once the same attribute should not be
repeated in another entity if it is describing the same information. For example: price can
be an attribute of FOOD ITEM, but total price of an ORDER can be derived so it should
not be an attribute there.
Assess for understanding by asking students if entities change depending on the type of
database, computer, or programming language used. Answer: No. This is what is meant
when we say that data modeling is implementation-free.
Connections
Reiterate that the ERD is a tool for discussion, especially when designing a system. It
gives you and the customer something to react to, validate, and correct. Ask students to
think back to the Dream House activity. When the student who wanted the dream house
saw the picture that the other student had drawn, the student knew that the other person
either (a) got it right! or (b) got it wrong. Thats how an ERD works.
Other examples that help illustrate this point: getting a haircut based on a picture in a
magazine (have you ever forgotten the picture?); having a dress made from a picture in a
magazine (what if you could only explain it?); describing a gift you want to your parents
whove never seen this item. Pictures help!
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn it?
Entity relationship diagram (ERD): A drawing that is used to represent a data model
Tell students that they need to know what an ERD looks like they will be drawing
ERDs in the next section and throughout the course. This is where students become
architects and draw their clients dream models.
Slide 4: Tell Me / Show Me Implementation-Free Models
Implementation free: Not dependent on the physical model
Database Types: Hierarchical, Relational, Network
This picture shows us that an ER model captures business information that can be used as
a basis for any database. The ER model tells us something about the business, not about
Oracle Academy

7
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
the implementation. Having said that, in practice, the majority of the ER models lead to
relational database implementations.
Slide 5: Tell Me / Show Me What is an Entity Relationship Model?
No notes for this slide.
Slide 6: Tell Me / Show Me Goals of ER Modeling
An Entity Relationship Diagram (ERD) is a picture, a representation of the model or a
part of the model.
Discussion points using the school-record example:
Where does the school store student information? How is it stored?
Who is responsible for updating changes to student information?
What information indicates that a student is eligible for graduation?
Have you ever updated information only to be asked to do it again?
What happens to student data when the school gets new database computers?
How do you locate your information among all the other student records?
How do your grades not get confused with another student with the same last name?
Slide 7: Tell Me / Show Me DJs on Demand Business Scenario
The DJs on Demand scenario is referenced in several lessons later in the course, in
which the completed ER model is built up piece-by-piece.
You will be showing the ER model to the class as an example of a complete data model.
This will contain supertypes/subtypes, arcs, barred relationships, and other data-modeling
techniques that you have not taught yet. Just explain that by the end of the course, they
will know what it all means. For now, focus on the entity names in softboxes and on the
attributes inside the softbox, which are mandatory (*) and which are optional (o). Point
out the relationships. These are coming up in the next section.
Drawing conventions will be discussed in another lesson, so you may not want to use the
terms softbox when going over the ERD. You may not even want to go over the
drawing conventions for mandatory and optional attributes (* vs. o), but it is all right if
some students deduce this from your demonstration.
Slide 8: Tell Me / Show Me DJs on Demand continued:
No instructor notes for this slide
Slide 9: Tell Me / Show Me DJs on Demand continued:
No instructor notes for this slide
Slide 10: Tell Me / Show Me DJs on Demand continued:
No instructor notes for this slide
Oracle Academy

8
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 11: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 12: Summary In this lesson you have learned how to:
No instructor notes for this slide
Slide 13: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

9
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Practice Solutions
SECTION 2 Conceptual & Physical Models Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Physical model

A design for an object (a car, a house, a database,


etc.) which includes implementation details such as
size, volume, weight, etc.)

Conceptual model

A data model, usually represented by an entityrelationship diagram.

Data

A collection of facts from which conclusions may be


drawn.

Data model

The product of the database design process which


aims to identify and organize the required data

Try It / Solve It
1. You will be working in pairs for this activity.

One student describes his/her dream house while the other student attempts to
draw it.
You can discuss specific details, but the student describing the house is not
allowed to see what is being drawn until after time is called.

After sharing your drawing describe the importance of accurately describing


information requirements.

Oracle Academy

10
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Solution: The objective of the dream-house activity is for students to demonstrate
precise communication as a means to facilitate discussion and prevent mistakes and
misunderstandings. Working in pairs, one student describes his/her dream house
while the other student attempts to draw it. The pairs can discuss specific details, but
the student describing the house is not allowed to see what is being drawn until after
time is called.

Collect student drawings and tape to the board/wall.


Ask volunteer student pairs to describe the discrepancies between what they
thought was being described and what was actually drawn.
Solicit student ideas on how they would improve the communication process
if they were to do the same activity again.

Possible answers may include: Describe shapes and colors. Describe relative sizes
(bigger than a hut, smaller than a hotel, etc.) Be specific (2 doors, 3 stories, 5
windows, etc.). Make comparisons to known things (similar to Marys house, like a
castle, etc.).
Other ways to test for understanding: Make sure that the students understand the
difference between a conceptual and a physical data model by presenting examples
and asking them to identify them as conceptual or physical:
Blueprint of a house versus a house
Sketch of an outfit/dress/suit versus the real thing
Recipe for a cake versus the cake itself
If you can show actual samples of the above (house plans, draw a dress/suit on the
board, print out a recipe), that would drive home the point even better. Feel free to
supplement with other examples that are more familiar or accessible to you.
2. Review the scenario below. Identify the conceptual model and the physical model
from the scenario.
Zoe was about to go into a store to purchase drinks for the birthday party
scheduled for that evening. Zoe knows that she needs drinks for 48 people and is
expecting the store to accept a check for payment and to provide her with some
assistance carrying the product to her car. Zoe wants to have carbonated drinks,
non-carbonated drinks, and sugar free drinks. She is expecting to purchase 4 six
packs. Zoe enters the store and discovers the entire drink distribution system is
automated. She also discovers that the drinks come in varying package sizes and
that she must choose the correct vending option for the products to be disbursed.
Drinks are packaged in four packs, six packs, and ten packs, which is not what
Zoe expected.

Oracle Academy

11
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Solution:
Conceptual model Selecting products, providing a check for payment to a person,
and having a person assist with carrying the products out of the store.
Physical implementation Automated vending system requiring payment for each
product distributed. No one available to assist with carrying the products out of the
store.
3. Provide five reasons for creating a conceptual data model.
Answers will vary but can include any of the following:
Describe exactly the information needs of the business
Facilitate discussion
Prevent mistakes, misunderstandings
Form important ideal system documentation
Form a sound basis for physical database design
Document the processes of the business (this is also known as the business
rules)
Take into account regulations and laws governing this industry
4. List two examples of conceptual models and physical models.
Answers will vary but should illustrate the understanding that the conceptual model
is the thought and the physical model is the actual implementation of the thought.

Oracle Academy

12
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 2 - Entities, Instances, Attributes and Identifiers Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Mandatory

Required.

Nontangible/ Intangible

Incapable of being perceived by the senses.

Unique Identifier (UID)

Any combination of attributes and/or relationships


that serves, in all cases, to uniquely identify an
occurrence of an entity.

Instance

An occurrence or example.

Attribute

Characteristic, something that describes, quantifies


or specifies an entity.

Optional

Not required.

Entity

A named thing or category of things that is


significant to the business and about which data must
be known.

Null

A value that is unavailable, unassigned, unknown, or


inapplicable; it is not a zero or space.

Volatile

Highly changeable.

Tangible

Perceptible by the senses, especially the sense of


touch

Datatype

A classification identifying one of various types of


data, stating the possible values for that type, the
operations that can be done on that type, and the way
the values of that type are stored

Single Valued

Can only have one value at any point for each


instance in the entity

Oracle Academy

13
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Try It / Solve It
1. Consider the entity STUDENT. You are all students in a class. However, each one of
you is a unique instance of that entity. Your teacher will lead you through an exercise
to demonstrate this.
Solution: Say, STUDENTS please stand up. Have everyone sit down and then say,
Julie Miller (or some specific student in your class), please stand up.
Then explain that while they are all students, Julie Miller is a specific instance of
STUDENT.
Have students write on a 3 x 5 note card the answers to the questions below, or fill
out a preprinted sheet of paper with the following information:
Month of birthday
Color of shirt/blouse
Shoe color
Color of backpack/school bag
Glasses/no glasses
Year in school
Eye color
Has a pet cat/dog/bird
Right/left-handed
Number of brothers and sisters
Note: The specific traits can be varied as long as there are six or more different traits.
You need at least six traits to uniquely identify a student.
Collect the card/paper from each student. Ask all students to stand up. Randomly
select one students card/paper. Ask a question for each trait that the students
recorded. You are trying to eliminate other students until you are left with only the
student whose card you have. This student is your INSTANCE. For example:
a. Will all those students who were born before or after (the month listed on the
selected card) please sit down?
b. Will all those students who are not wearing shoes of color (the color on
selected card) please sit down?
c. Will all those students who (wear/not wear) glasses please sit down?
d. Will all those students who do not have eye color (eye color on selected card)
please sit down?
e. Will all those students who are (left/right)-handed please sit down?
f. Will all those students who have fewer or more siblings than (number of
brothers and sisters) please sit down?
Make sure students can distinguish between entities and instances. Ask them how you
can distinguish one student from another. You can ask them to provide answers now
Oracle Academy
14
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
(name, gender, hair color, etc.), but tell them that these are attributes and will be
discussed further later.
Ask students which traits would make good attributes to identify someone:
Does the month of your birthday ever change?
Does your shoe color change?
What other traits could be added if shoe color and glasses are eliminated?
2. Think about the last time you went to get a haircut, permanent, manicure, or other
service from a barbershop or hair salon.
Discuss the business of a barbershop or hair salon. Name the entities that are the
main things about this business. Give examples of instances for each entity.
Solution:
Customer Vishal Gupta
Services color, cut, permanent wave, manicure, shampoo
Employees/technicians stylist, shampoo person, cashier, receptionist
Products shampoo, color, styling gel, lotion
Tools hair dryer, scissors
Note: In naming entities, the class may also be including attributes. If they do this,
correct them, and identify them as attributes, and tell them that we will discuss the
difference more in the next lesson.
3. The goal of this activity is to learn to make a distinction between an entity, an
attribute, and an instance of an entity. List which of the following concepts you think
is an entity, attribute, or instance. If you determine that one is an entity, then give an
example of an instance. If you determine that one is an attribute or an instance, give a
sample entity name. For the last three rows, find a concept that fits.
Concept
Vehicle
Diet Cola
Price
Customer number
Green

Oracle Academy

Entity? Attribute? Instance?

Example instance or Entity

Entity
Attribute
Instance

Cookie
Cookie
Cookie

15
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Solution: In order to guide students in the direction of the given solution, you may
want to provide business contexts for each concept, such as:
Vehicle (a car-rental agency)
Diet Coke (a restaurant)
Price (a department store)
Customer number (an online catalog)
Green (a botanical garden)
Cookie (a restaurant)
Alternative answers may be considered acceptable, if the student can argue
successfully and provide a business context or rule for it.
4. The goal of this practice is to recognize attributes for an entity.
The three entities that play a role in a DJ business: SONG, EVENT, and
CUSTOMER are listed as the first three column headings of the table below. The
fourth column contains a collection of attributes. Use a check mark to indicate if the
attribute listed could be an attribute for the entities listed. (For example, could Title
be an attribute for Song, for Event, and for Customer?)
SONG

EVENT

CUSTOMER
Title
Description
Venue
First Name
Phone Number
Release date
Last Name
Type
Email address

Oracle Academy

16
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Solution: The three entities that play a role in a DJ business: SONG, EVENT, and
CUSTOMER are listed as the first three column headings of the table below. The
fourth column contains a collection of attributes. Use a check mark to indicate if the
attribute listed could be an attribute for the entities listed. (For example, could Title
be an attribute for Song, for Event, and For Customer?)
SONG
X
X

EVENT

CUSTOMER

X
X
X
X

X
X
X

X
X

Title
Description
Venue
First Name
Phone Number
Release date
Last Name
Type
Email address

5. From the list of attributes provided, identify which attribute could be the unique
identifier of each entity.
Entity: STUDENT
Attributes: student ID, first name, last name, address
UID: student ID
Entity: MOVIE
Attributes: title, date released, producer, director
UID: a combination of title and date released, or an artificial UID such as movie
ID
Entity: LOCKER
Attributes: size, location, number
UID: number
6. Read the given business scenario and walk through the steps below.
Im the owner of a small movie rental store. We have over 3,000 movies that we
need to keep track of.
Each of our movies has a DVD or VHS tape number. For each movie, we need
to know its title and category (e.g., comedy, suspense, drama, action, war, or scifi).
Oracle Academy

17
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Yes, we do have multiple copies of many of our movies.
We give each movie a specific ID, and then track which DVD or VHS contains
the movie. A movie can be either DVD or VHS format.
We always have at least one DVD or VHS tape for each movie we track, and
each DVD or VHS tape is always a copy of a single, specific movie.
Our DVDs and VHS tapes are very long. We dont have any movies that require
multiple DVDs or VHS tapes.
a. Write a list of nouns used in the scenario.
owner, store, movie, DVD, VHS tape
b. Name each entity.
media, customer, movie, actor
c. Is each instance of the entity uniquely identifiable? Which attribute or attributes
could serve as the unique attribute to identify the entity?
movie number, customer number, actor name, media number
7. Identify the business rules contained in the following scenario.
We are frequently asked for movies starring specific actors. John Wayne and
Julia Roberts are always popular. So wed like to keep track of the star actors
appearing in each movie. Not all of our movies have star actors. Customers like to
know each actors real birth name and date of birth. We track only actors who
appear in the movies in our inventory.
Solution:
Track actors for each movie in the inventory.
Track actor birth names for each actor
Track actor date of birth for each actor
8. Identify the business rules contained in the following scenario.
We have lots of customers. We rent videos only to people who have joined our
video club. To belong to our club, they must have good credit. For each club
member, wed like to keep their first and last name, current phone number, and
current address. And, of course, each club member has a membership number.

Oracle Academy

18
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Then we need to keep track of what movie each customer currently has checked
out. A customer may check out multiple video tapes at any given time. We just
track current rentals. We dont keep track of any rental histories.
Solution:
Customers must have a membership number
Movies are only rented to customers
Customers must have a good credit rating
Customer information captured includes first and last name, phone number,
and address.
Customer rental history includes current rental only
Customer rental history can include more than one movie
9. Age is an example of what type of attribute?

Volatile attribute

10. Birth date is an example of what type of attribute?

Non-volatile attribute

11. Read the business scenario of a fast-food restaurant below:


We are a small fast food business. Our menu features food items that can be
ordered by a customer. A customer places an order at the counter and indicates
what food items he/she would like on that order.
Lately weve noticed that we have some regular customers, so we started asking
them for information such as name and address, so we can mail them coupons
when we have specials.
a. Using the restaurant entities ORDER, FOOD ITEM, AND CUSTOMER, identify
the attributes for each entity.
b. Where possible, indicate whether the attribute is mandatory or optional.
c. Where possible, pick out the UIDs for each entity
Solution: This restaurant business scenario is an offshoot version of the progressive
project, Global Fast Foods, which students will be building throughout the course.
There is not a definitive solution for this activity but the answer can be similar to the
Global Fast Foods model. Some students may want an entity called MENU, with food
item as an attribute. Be careful with this one: although MENU could be a valid entity,
food item as an attribute would be repeating: there would be many different food
items on a menu. Therefore, even with MENU as an entity, you would still need
FOOD ITEM as another entity. Attributes of menu could be name, hours served, etc.
Ask students why they would choose to make an attribute mandatory or optional. This
makes them start thinking about business rules.
Oracle Academy

19
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
UID for ORDER could be number, UID for FOOD ITEM could be name (or ID), and
UID for CUSTOMER could be name and address together or ID.

Oracle Academy

20
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 2 Entity Relationship Modeling and ERDs Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Implementation-free

Not dependent on the physical model.

Entity relationship diagram


(ERD)

A drawing that is used to represent a data model.

Try It / Solve It
1. True or False: To be described as implementation-free a data model must be changed
to accommodate the database system onto which it is built.
False
2. True or False: To be described as implementation-free a data model must not change
to accommodate the database system onto which it is built.
True
3. List four goals of entity relationship modeling.
Capture all required information
Ensure that information appears only once
Model no information that is derivable from other information already
modeled
Locate information in a predictable, logical place
4. An ___ERD_______ is a consistent tool that can be used to represent data
requirements regardless of what type of database is used.

Oracle Academy

21
Database Design
Copyright 2011, Oracle. All rights reserved.

Identifying Relationships

Copyright 2011, Oracle. All rights reserved.

Identifying Relationships

What Will I Learn?


Objectives
In this lesson, you will learn to:
Interpret and describe relationship optionality
Interpret and describe relationship cardinality
Relate entities by applying the rules of cardinality and
optionality

Copyright 2011, Oracle. All rights reserved.

Identifying Relationships

Why Learn It?


Purpose
Being able to identify the relationships between entities makes
it easier to understand the connections between different
pieces of data.
It helps you see how different parts of a system affect each
other. For example, the entities STUDENT and COURSE are
related to each other.
To accurately model the business, the relationships are as
important as the entities themselves.

Copyright 2011, Oracle. All rights reserved.

Identifying Relationships

Tell Me / Show Me
Relationships in Families
What is the relationship between you and your aunt, you and
your uncle, your cousins, your grandmother, etc? What would a
society be like that did not categorize relatives as aunts, uncles,
cousins, grandmothers and grandfathers but only by their name?
How could you tell someone that Jenny was your cousin?
It would be a long and potentially confusing introduction, like
This is Jenny, who is the child of the woman who has the same
parents as my parent who is a woman, as opposed to This is
Jenny, my mothers sisters child, or This is Jenny, my aunts
child, or the simplest one This is Jenny, my cousin.

Notice that we still use a basic relationship in the longest


introduction -- that of child to parent. Without that relationship it
would be very difficult to introduce anyone beyond giving their
name!
Copyright 2011, Oracle. All rights reserved.

Identifying Relationships

Tell Me / Show Me
Relationships in Data Models
Relationships:
Represent something of significance/importance to the
business
Show how entities are related to each other
Always exist between two entities (or one entity twice)
Always have two sides
Are named at both ends
Have an optionality
Have a degree or cardinality

Copyright 2011, Oracle. All rights reserved.

Identifying Relationships

Tell Me / Show Me
What is Optionality in a Relationship?
Relationships are either mandatory or optional. Based on what you
know about instances of the entities, you can determine optionality
by answering four questions:
Must every employee have a job? In other words, is this a
mandatory or optional relationship for an employee?
Can employees have more than one job?
Must every job be done by an employee? (In other words, is this
a mandatory or optional relationship for a job?)
Can each job be done by more than one employee?

Copyright 2011, Oracle. All rights reserved.

Identifying Relationships

Tell Me / Show Me
What is Cardinality in a Relationship?
Cardinality of a relationship determines the degree of a
relationship. It answers how many.

For example:

How many jobs does an employee hold? One or more? Just


one?
A job may be held by how many employees? Just one? One or
more?

Copyright 2011, Oracle. All rights reserved.

Identifying Relationships

Tell Me / Show Me
Optionality and Cardinality
Examples:
Each EMPLOYEE must hold one and only one JOB
Each JOB may be held by one or more EMPLOYEEs

Each PRODUCT must be classified by one and only one


PRODUCT TYPE
Each PRODUCT TYPE may classify one or more
PRODUCTs

Copyright 2011, Oracle. All rights reserved.

Identifying Relationships

Tell Me / Show Me
Relationships

Each SEAT may be sold to one


or more PASSENGERs

Each PASSENGER may


purchase one SEAT

SEAT is sold to a PASSENGER


(or PASSENGERs -- hence,
overbooking)

PASSENGER purchases or
books a SEAT

Copyright 2011, Oracle. All rights reserved.

SEAT

PASSENGER

Identifying Relationships

Tell Me / Show Me
Business Scenario 1
What are the relationships in the
following business scenario?
We like to classify all our music, each
song or soundtrack, by type. The
different types are rock, jazz, country,
classical, pop, new age, etc. We can
add new types as the need arises. In
fact, we recently added a new type for
rap music. We realize that a song can
really be classified under more than one
type, but for our purposes we select
only one main classification type for
each song."

RELATIONSHIP

SONG
(music/soundtrack) is
classified by TYPE

TYPE is a classification
for SONG

Copyright 2011, Oracle. All rights reserved.

10

Identifying Relationships

Tell Me / Show Me
Business Scenario 1
(continued)
SONG has a TYPE: optionality
and cardinality

SONG
Stairway to Heaven

TYPE

Optionality = Must or may?

Green Dolphin Street

Each SONG must be classified


by one (and only one) TYPE.
Each TYPE may be a
classification for one or more
SONGs.

rock
jazz
new age

classical
pop

Minute Waltz
Pachelbel Canon
Thriller
Stand By Your Man

country

Cardinality = How many?


Each SONG must be classified
by one (and only one) TYPE.
Each TYPE may be a
classification for one or more
SONGs.

Copyright 2011, Oracle. All rights reserved.

11

Identifying Relationships

Tell Me / Show Me
SONG

Business Scenario 1
(continued)

TYPE

Green Dolphin Street

SONG has a TYPE


What if there is no TYPE for
a SONG?

Stairway to Heaven

rock
jazz
new age

classical
pop

country

Do the business rules state


that every SONG has a
TYPE? If yes, then an
additional TYPE needs to be
added.

Copyright 2011, Oracle. All rights reserved.

Minute Waltz
Pachelbel Canon
Thriller
Stand By Your Man

Amazing
Grace

12

Identifying Relationships

Tell Me / Show Me
SONG

Business Scenario 1
(continued)
TYPE

SONG has a TYPE

Stairway to Heaven
Green Dolphin Street

rock

Can you have a TYPE with


no SONG?

jazz
new age

classical
pop

Why would you have a


TYPE with no SONG?

Minute Waltz
Pachelbel Canon
Thriller
Stand By Your Man

country

Copyright 2011, Oracle. All rights reserved.

13

Identifying Relationships

Tell Me / Show Me
Business Scenario 1
(continued)
SONG has a TYPE

SONG

TYPE

How many TYPEs can a


SONG belong to?

Business rules determine


cardinality.
If a SONG can belong to
more than one TYPE the
cardinality would be stated
as:

Stairway to Heaven
Green Dolphin Street

rock
jazz
new age

classical

pop

Minute Waltz
Pachelbel Canon
Thriller
Stand By Your Man

country

Each SONG must be


classified by one or more
TYPEs.
Copyright 2011, Oracle. All rights reserved.

14

Identifying Relationships

Tell Me / Show Me
Business Scenario 2
What are the relationships in the
following business scenario?

In our restaurant, customers come up


to the counter and place their orders. A
customer can order for himself/herself
or for a whole group of people. For
example, if a mother orders for herself
and her children, we consider that
mother to be the customer who owns
the order and who is responsible for
payment. Of course, the customer can
place as many orders as he/she wants.

RELATIONSHIP

CUSTOMER places
ORDERS
An ORDER is placed
by one CUSTOMER

Copyright 2011, Oracle. All rights reserved.

15

Identifying Relationships

Tell Me / Show Me
CUSTOMER

Business Scenario 2
(continued)

Linda

CUSTOMER has ORDERs:


optionality and cardinality

Krishna
Mel

Optionality = Must or may?

Each ORDER must be placed by


one (and only one) CUSTOMER.
Each CUSTOMER must place
one or more ORDERs.

Cardinality = How many?


Each ORDER must be placed by
one (and only one) CUSTOMER.
Each CUSTOMER must place
one or more ORDERs.

ORDER
Order No. 100
-French fries
- Large soda
Order No. 102
- Apple pie

Order No. 77
-Hamburger
- Salad
- Fruit cup

Order No. 10
-Vegetarian platter
- Orange juice

Copyright 2011, Oracle. All rights reserved.

16

Identifying Relationships

Tell Me / Show Me
Business Scenario 3
A relationship can relate an
entity to itself. Examine the
following scenario.
We need to keep track of our
employees and their
managers. Every employee
has one manager, including
the managing director, who
manages him/herself. Each
manager can manage several
employees.
Since managers are also
employees, there is only one
entity here: EMPLOYEE.

RELATIONSHIP
An EMPLOYEE manages EMPLOYEEs
An EMPLOYEE is managed by one EMPLOYEE

Copyright 2011, Oracle. All rights reserved.

17

Identifying Relationships

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Cardinality/Degree
Relationship
Optionality

Copyright 2011, Oracle. All rights reserved.

18

Identifying Relationships

Summary
Objectives Summarized
In this lesson, you have learned how to:
Interpret and describe relationship optionality
Interpret and describe relationship cardinality
Relate entities by applying the rules of cardinality and
optionality

Copyright 2011, Oracle. All rights reserved.

19

Identifying Relationships

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

20

ER Diagramming Conventions

Copyright 2011, Oracle. All rights reserved.

ER Diagramming Conventions

What Will I Learn?


Objective
In this lesson, you will learn to:
Construct ER diagram components that represent
entities and attributes according to diagramming
conventions

Copyright 2011, Oracle. All rights reserved.

ER Diagramming Conventions

Why Learn It?


Purpose
People speak different
languages throughout the
world, but some signs are
understood globally.
Guess the meaning of these
signs.

International Signs

Copyright 2011, Oracle. All rights reserved.

ER Diagramming Conventions

Why Learn It?


Sign Review
How well did you do?

International Signs

Did you guess the


meaning of most
signs?

Key:

1.
Crosswind
4. Lane for slow vehicles 6. Low clearance
2.
Roundabout
5. Stop in Brazil
7. Mr. Yuk
3.
No entry for vehicles carrying more than a certain quantity of
explosives or readily inflammable substances

Copyright 2011, Oracle. All rights reserved.

ER Diagramming Conventions

Tell Me / Show Me
Shared Convention
It is efficient to communicate
information in a way that can be
easily understood by many
people.

ER diagramming is like that -you may say or write things


differently because of the way
you speak, your accent, and so
on, but everyone draws
diagrams according to the
same conventions.

Copyright 2011, Oracle. All rights reserved.

A Shared
Convention

ER Diagramming Conventions

Tell Me / Show Me
DJs on Demand: Clients, Events,
and Types
"Our client list is growing. We have a
lot of repeat business -- customers
who like what weve done who ask
us to work for them again. We have
some very busy customers who can
have more than one event going on
at the same time. Each partner has
some specialty or expertise -- so
when its appropriate, we like to
classify our events by theme to help
us assign the right person (partner)
to the job. An event theme can be a
beach party, medieval, carnival, retro
sixties or seventies, etc. We keep
adding event themes as we go."

CLIENT
# number
# first name
# last name
o phone
number

EVENT
# id
* name
* date
o description
o cost

Copyright 2011, Oracle. All rights reserved.

THEME
# code
* description

ER Diagramming Conventions

Tell Me / Show Me
ER Drawing Conventions
Entities are represented by
softboxes.
Entity names go in the
softboxes.
Entity names are always
singular and written with all
capital letters.

CLIENT

EVENT

Copyright 2011, Oracle. All rights reserved.

THEME

ER Diagramming Conventions

Tell Me / Show Me
Drawing Conventions
Attributes are listed under the
entity names.
Mandatory attributes are
marked with an asterisk: *
Optional attributes are marked
with a circle: o
Unique identifiers are marked
with a hash sign: #

CLIENT
# number
* first name
* last name
* phone number
o email address

EVENT
# id
* name
* date
* cost
* description

Copyright 2011, Oracle. All rights reserved.

THEME
# code
* description

ER Diagramming Conventions

Tell Me / Show Me
Drawing Conventions
(continued)
Relationships are lines that
connect entities.
These lines are either solid or
dashed.
These lines terminate in a
single toe
or a crows foot at the end of
each entity.
You will learn more about the
meaning of relationship lines in
the next lesson.

CLIENT
# number
* first name
* last name
* phone number
o email address

Single Toe
Crows Foot

EVENT
# id
* name
* date
* cost
* description

Copyright 2011, Oracle. All rights reserved.

THEME
# code
* description

ER Diagramming Conventions

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Softbox

Copyright 2011, Oracle. All rights reserved.

10

ER Diagramming Conventions

Summary
Objective Summarized
In this lesson, you have learned how to:
Construct ER diagram components that represent
entities and attributes according to diagramming
conventions

Copyright 2011, Oracle. All rights reserved.

11

ER Diagramming Conventions

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

12

Speaking ERDish and Drawing


Relationships

Copyright 2011, Oracle. All rights reserved.

Speaking ERDish and Drawing Relationships

What Will I Learn?


Objectives
In this lesson, you will learn to:
State relationships between entities in precise words
(ERDish)
Draw and label relationships correctly on an ERD

Copyright 2011, Oracle. All rights reserved.

Speaking ERDish and Drawing Relationships

Why Learn It?


Purpose
Most businesses have a unique terminology (words which
have a special meaning within that business) that people
speak in order to communicate information.
Data modeling also has a unique terminology as well,
which we call ERDish for the purposes of this class.
Learning how to create ERDs and speak ERDish gives you
a common terminology with your clients and with Database
Administrators who will implement your design.

Copyright 2011, Oracle. All rights reserved.

Speaking ERDish and Drawing Relationships

Tell Me / Show Me
Review A Scene
View the following scene between
the waiter placing orders and the
chef.
Why did the waiter have trouble at
the end?
sdm_s03_l03_a01

Copyright 2011, Oracle. All rights reserved.

Speaking ERDish and Drawing Relationships

Tell Me / Show Me
ERD Language
ERDish is the language we
use to state relationships
between entities in an
ERD.

Breaking Down ERDish

EMPLOYEE

working in

DEPARTMENT
the cost
center for

You have already been


speaking and writing it,
when you identified
relationships and specified
optionality and cardinality.
We are simply breaking
down each ERDish
sentence into its
components.

Copyright 2011, Oracle. All rights reserved.

Speaking ERDish and Drawing Relationships

Tell Me / Show Me
The components of
ERDish

1. EACH
2. Entity A
3. OPTIONALITY
(must be/may be)
4. RELATIONSHIP
NAME
5. CARDINALITY
(one and only
one/one or more)
6. Entity B

Breaking Down ERDish

EMPLOYEE

1.
2.
3.
4.
5.
6.

working in

DEPARTMENT

EACH
EMPLOYEE (entity A)
MUST BE (optionality, solid line)
WORKING IN (relationship name)
ONE (cardinality, single toe)
DEPARTMENT (entity B)

Since each relationship has two sides, we read the first relationship
from left to right (or top to bottom, depending on the ERD layout).

Copyright 2011, Oracle. All rights reserved.

Speaking ERDish and Drawing Relationships

Tell Me / Show Me
The components of
ERDish (continued)

1. EACH
2. Entity A
3. OPTIONALITY
(must be/may be)
4. RELATIONSHIP
NAME
5. CARDINALITY
(one and only
one/one or more)
6. Entity B

Breaking Down ERDish

EMPLOYEE

DEPARTMENT
the cost
center for

1.
2.
3.
4.
5.
6.

EACH
DEPARTMENT (entity B)
MAY BE (optionality, dotted line)
THE COST CENTER FOR (relationship name)
ONE OR MORE (cardinality, crows foot)
EMPLOYEE (entity A)

Now we read the second relationship from right to left.

Copyright 2011, Oracle. All rights reserved.

Speaking ERDish and Drawing Relationships

Tell Me / Show Me
The components of
ERDish (continued)

1. EACH
2. Entity A
3. OPTIONALITY
(must be/may be)
4. RELATIONSHIP
NAME
5. CARDINALITY
(one and only
one/one or more)
6. Entity B

Breaking Down ERDish

working in

EMPLOYEE

DEPARTMENT
the cost
center for

1.
2.
3.
4.
5.

EACH
EMPLOYEE (entity A)
MUST BE (optionality, solid line)
WORKING IN (relationship name)
ONE AND ONLY ONE
(cardinality, single toe)
6. DEPARTMENT (entity B)

1.
2.
3.
4.

EACH
DEPARTMENT (entity B)
MAY BE (optionality, dotted line)
THE COST CENTER FOR
(relationship name)
5. ONE OR MORE (cardinality, crows
foot)
6. EMPLOYEE (entity B)

Now bring it together.

Copyright 2011, Oracle. All rights reserved.

Speaking ERDish and Drawing Relationships

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
ERDish

Copyright 2011, Oracle. All rights reserved.

Speaking ERDish and Drawing Relationships

Summary
Objectives Summarized
In this lesson, you have learned how to:
State relationships between entities in precise words
(ERDish)
Draw and label relationships correctly on an ERD

Copyright 2011, Oracle. All rights reserved.

10

Speaking ERDish and Drawing Relationships

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.
Before the practice activities review the animation below.

sdm_s04_l02_a02

Copyright 2011, Oracle. All rights reserved.

11

Matrix Diagrams

Copyright 2011, Oracle. All rights reserved.

Matrix Diagrams

What Will I Learn?


Objectives
In this lesson, you will learn to:
Identify relationships using a matrix diagram
Draw an ERD from a matrix diagram

Copyright 2011, Oracle. All rights reserved.

Matrix Diagrams

Why Learn It?


Purpose
It is useful to know
more than one way
of discovering
relationships.

TEACHER

COURSE

CLASS

The matrix diagram


is a good way to
make sure that we
havent missed any
relationships -especially useful
when you are
dealing with a lot of
entities.

TEACHER

COURSE

STUDENT

CLASS

EXAM

SEMESTER

CAFETERIA

GRADE

CLASSROOM

SCHOOL

etc.

It may be simple enough


to identify relationships
given three entities.

Copyright 2011, Oracle. All rights reserved.

CLUB

SCHOOL
EQUIPMENT

MAINTENANCE
STAFF

But what about finding


relationships when you
have thirteen or more
entities?

Matrix Diagrams

Tell Me / Show Me
Business Scenario
"I work for a travel agency.
I keep a record of the
countries that our
customers have visited
and the landmarks theyve
seen in each country. It
helps us customize tours
for them."

We can use the matrix


diagram to uncover
relationships.

COUNTRY

TRAVELER
LANDMARK

TRAVELER

COUNTRY

LANDMARK

TRAVELER

COUNTRY

LANDMARK

MATRIX DIAGRAM

Copyright 2011, Oracle. All rights reserved.

Matrix Diagrams

Tell Me / Show Me
Matrix Diagrams
Relationships
discovered via the
matrix diagram are
drawn on the ERD.
Matrix diagrams do not
show optionality and
cardinality.
Each COUNTRY may
be visited by one or
more TRAVELERs.

TRAVELER
TRAVELER
COUNTRY
LANDMARK

TRAVELER

COUNTRY

LANDMARK

visit

have seen

visited by
seen by

the location of

located in

visit

COUNTRY
visited by
the location of

have seen

Copyright 2011, Oracle. All rights reserved.

located in
Seen by

LANDMARK

Matrix Diagrams

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Matrix diagram

Copyright 2011, Oracle. All rights reserved.

Matrix Diagrams

Summary
Objectives Summarized
In this lesson, you have learned how to:
Identify relationships using a matrix diagram
Draw an ERD from a matrix diagram

Copyright 2011, Oracle. All rights reserved.

Matrix Diagrams

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
INSTRUCTOR NOTES
SECTION 3 Identifying Relationships Lesson
Slide 1: Identifying Relationships
Lesson Preparation
The previous section introduced entities and attributes.
Relationships are the third component of a data model (the R in ER modeling).
This section starts by identifying relationships between entities. Then it examines the
characteristics of and rules regarding relationships.
What to Watch For
Have students go over each of the relationships shown in the Try It / Solve It activities,
and change the business rules (example: any WAITER can take any ORDER from any
table).
Then have them restate the relationship with the revised cardinality and/or optionality.
Connections
We could use a familiar example here because it has many possibilities:
TEACHERS/COURSES/STUDENTS
Teachers may teach courses (part-time teachers may have the term off).
Are all courses taught by teachers? What about online courses?
Students attend courses. Must students take a course to be considered a student?
Can there be a course with no student?
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
Relationship: A connection or association between objects
Other discussion points for why it is important to understand relationships:
What is the relationship between student and library book? (What would you do if you
received a fine for a book checked out by another student?)
You would certainly protest because the student who checked out the book (this is
the relationship) should also be responsible for any associated fines.
This emphasizes the importance of clarifying relationships, especially in a
business.
Slide 4: Tell Me / Show Me What is the relationship between you and
No instructor notes for this slide

Oracle Academy

1
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 5: Tell Me / Show Me Each Relationship:
Ask students: have you ever been scheduled for an airplane flight and heard the check-in
desk attendant ask if anyone wanted to give up their seat because the plane was
overbooked? Why does an airline sell one seat to two people? Is every seat sold to more
than one person? Why does it happen sometimes and not all the time? Is it normal for a
person to buy more than one seat for himself/herself on a plane?
Slide 6: Tell Me / Show Me Each SEAT may be sold
No instructor notes for this slide
Slide 7: Tell Me / Show Me Business scenario describing relationships:
Point out that this statement describes the basic relationship between SONG and TYPE,
but in order to fully capture the business rules, we need to revise the sentence to include
optionality and cardinality.
Slide 8: Tell Me / Show Me SONG has a TYPE: optionality and cardinality
Optionality: Must or may?
Encourage discussion about the business rules and how they affect optionality:
Must every SONG have a TYPE?
Cardinality: How many?
Slide 9: Tell Me / Show Me SONG has a TYPE
Can you have a SONG that doesnt fall under any one TYPE? Point out that in the
diagram, all SONGs are classified by a TYPE.
How would you classify a religious song when you dont have a type called religious?
Would you leave it without a type or would you create a new type? That is a decision that
is based on the business rules. In this particular business, ALL songs must have a type, so
you would create a new type.
Slide 10: Tell Me / Show Me SONG has a TYPE (continued)
Optionality (must or may?):
Must every TYPE describe or classify a SONG? Can you have a TYPE with no SONGS
under it? Point out that in the diagram, some TYPEs are not used to classify any SONGs
Why have type called New Age when you dont have any songs that can be classified
under it? Why would you have the type at all? Possible answer: to prepare for future
songs, since New Age seems to be an increasingly popular category.

Oracle Academy

2
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 11: Tell Me / Show Me SONG has a TYPE (continued)
Cardinality (how many?):
Encourage discussion about the business rules and how they affect cardinality:
Point out that in the business scenario, it is stated a SONG is classified under only one
TYPE. That is the rule of this particular business. However, ask the class if it is possible
for another business to classify a SONG under many TYPEs. Answer: quite possibly.
Tell them that this would change the cardinality of the relationship.
How many SONGs can fall under one TYPE?
Again, the diagram and the business scenario indicate that a TYPE may be used to
classify several SONGs. Its a bit far-fetched to think of a business where a TYPE must
apply to only one SONG, but ask the class if they can think of a scenario where this is
possible. Encourage them to think of what is logically possible and what is probably
unlikely.
Slide 12: Tell Me / Show Me Business scenario describing relationships:
Point out that this statement describes the basic relationship between ORDER and
CUSTOMER, but in order to fully capture the business rules, we need to revise the
sentence to include optionality and cardinality.
Slide 13: Tell Me / Show Me CUSTOMER has ORDERs:
Optionality (must or may?):
Encourage discussion about the business rules and how they affect optionality:
Must a CUSTOMER place an ORDER? Do you consider someone a CUSTOMER if
he/she has not placed an ORDER? The diagram indicates that all customers have orders;
therefore, someone who does not have an order is not a customer. Challenge the students
to imagine another business where you could have a customer with no order. Possible
answer: Some restaurants define a customer as anyone who enters the premises (uses the
restroom, public phone, etc.). In this case, the optionality of the relationship will change
to: Each CUSTOMER may place one or more ORDERs.
Discuss the other end of the relationship:
Must an ORDER be placed by a CUSTOMER, or can you have an ORDER that is not
placed by any CUSTOMER? Can anyone in class think of a case where this could be
true?
Cardinality (how many?):
How many ORDERs can one CUSTOMER place?
Again, have them think of the business. In the given scenario, a CUSTOMER can place
many ORDERs. Is it likely that in another business a CUSTOMER is allowed only one
ORDER? Probably not in the food business.
How many CUSTOMERs are responsible for a single ORDER?
The scenario states that only one CUSTOMER is responsible for an ORDER. However,
ask the class if theyve ever eaten at a restaurant where they asked the waiter to split the
payment for the bill between two or more credit cards. This would mean a different
Oracle Academy

3
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
cardinality for the relationship. Have them state it: Each ORDER must be placed by one
or more CUSTOMERs.
Slide 14: Tell Me / Show Me A relationship can relate an entity to itself
In section 4 we will see that MANAGER may be a subtype of EMPLOYEE. In order to
fully capture the business rules, we need to revise the relationship to include optionality
and cardinality:
Each EMPLOYEE must be managed by one and only one EMPLOYEE.
Each EMPLOYEE may manage one or more EMPLOYEEs.
Slide 15: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 16: Summary In this lesson you have learned how to:
No instructor notes for this slide
Slide 17: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

4
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 3 ER Diagramming Conventions Lesson
Slide 1: ER Diagramming Conventions
Lesson Preparation
No further lesson preparation information.
What to Watch For
Make sure students are naming both sides of the relationship and stating the optionality
and cardinality. This will help students draw it in the next lesson. Get them accustomed
to using must/must be or may/may be and one and only one or one or more.
Also point out that an attribute may be mandatory or optional depending on the business
and its rules. Give an example: an EMPLOYEEs eye color may be optional in a
restaurant business, but may be mandatory in a security organization. When naming
attributes, also mention their datatypes (number, date, character, etc.)
Make sure students understand that more than one relationship can exist between entities.
Example: different relationships between person and class (attend, teach, write). Also
watch out for the crows feet pointing the wrong way. Its a common mistake that should
be corrected early. You can also mention that ideally youd like to draw the relationships
so that the crows fly south and east," but that this is not a strict requirement.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It? People speak different languages
No instructor notes for this slide
Slide 4: Why Learn It? How well did you do?
After viewing the graphic and guessing the meaning of each sign, you can also use
another example international sign language.
Its another way for people to communicate without even talking out loud!
Slide 5: Tell Me / Show Me It is efficient to communicate information
No instructor notes for this slide
Slide 6: Tell Me / Show Me DJs on Demand: Clients, Events, and Types
No instructor notes for this slide
Slide 7: Tell Me / Show Me ER Drawing Conventions
Softbox: A four-sided visual element with rounded corners, used to represent an entity in
an ERD

Oracle Academy

5
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 8: Tell Me / Show Me Drawing Conventions
Mention that any attribute that is part of the UID is always mandatory.
So it is also acceptable to draw it with # and * before the name.
Slide 9: Tell Me / Show Me Drawing Conventions
When viewing the graphic that shows the relationships, just talk through it but tell
students that you will discuss the rules of how to draw relationships in more detail in the
next lesson.
Slide 10: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 11: Summary In this lesson you have learned how to:
No instructor notes for this slide
Slide 12: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

6
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 3 Speaking ERDish and Drawing Relationships Lesson
Slide 1: Speaking ERDish and Drawing Relationships
Lesson Preparation
No further lesson preparation information.
What to Watch For
Make sure students are naming both sides of the relationship and stating the optionality
and cardinality. This will help students draw it in the next lesson. Get them accustomed
to using must/must be or may/may be and one and only one or one or more.
Also point out that an attribute may be mandatory or optional depending on the business
and its rules. Give an example: an EMPLOYEEs eye color may be optional in a
restaurant business, but may be mandatory in a security organization. When naming
attributes, also mention their datatypes (number, date, character, etc.)
Make sure students understand that more than one relationship can exist between entities.
Example: different relationships between person and class (attend, teach, write). Also
watch out for the crows feet pointing the wrong way. Its a common mistake that should
be corrected early. You can also mention that ideally youd like to draw the relationships
so that the crows fly south and east, but that this is not a strict requirement.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
ERDish: The language or statements used to describe relationships between entities in an
entity-relationship diagram
Give examples of languages that end with ish English, Swedish (ask for other
examples from the class Finnish, Yiddish, etc.).
Encourage students to think abstractly. Suggest languages such as SCHOOLish that
would include such words as credits, TAs (teaching assistants), terms, primary, and
secondary (include words specific to your institution).
Slide 4: Tell Me / Show Me View the following scene between
Play the animation once, and then feel free to run it again, this time pausing at certain
points for discussion.
For example:
When the waiter gives the chef the list of orders pause and ask the class, Do you see a
problem here? (The waiter doesnt really specify which food items go on which orders).
Then continue playing and point out that now the waiter is confused as well, because he
didnt organize his food items according to orders either.
Oracle Academy

7
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 5: Tell Me / Show Me ERDish is the language we use to state
When building the ERDish it helps to draw a standard relationship on the board. You
can use ORDER and ORDER ITEM to relate it to the animation, or whatever you are
comfortable with.
Slide 6: Tell Me / Show Me The components of ERDish:
Read your diagram on the board from left to right, pointing out the ERDish components
or highlighting them in a different color.
Slide 7: Tell Me / Show Me The components of ERDish:
Read your diagram on the board from right to left, pointing out the ERDish components
or highlighting them in a different color.
Slide 8: Tell Me / Show Me The components of ERDish:
Read your diagram on the board from left to right, and then right to left, pointing out the
ERDish components or highlighting them in a different color.
Stress the diagramming conventions: optionality by a solid (must) or dashed (may) line,
cardinality by a single line (one and only one) or crows feet (one or more).
Slide 9: Summary
No instructor notes for this slide
Slide 10: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 11: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

8
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 3 Matrix Diagrams Lesson
Slide 1: Matrix Diagrams
Lesson Preparation
The matrix diagram is a quick topic.
This activity should take no more than 10 minutes, leaving 20 minutes for the quiz and 10
minutes for assessment.
What to Watch For
Note that if an entity is related to itself, a cell on the diagonal will also contain a
relationship.
Connections
Go Over Activity: Photography
Ask these questions of the class:
Are the films developed in the same lab or in different labs?
Does the photographer develop any of his/her films?
Is a roll of film used on only one subject or on different subjects?
Are all the pictures on a roll of film taken under the same conditions or do they
vary?
Although students may not know how to model the answers at this point, just tell them
that these are examples of business rules that they will learn how to represent in the ERD.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
Matrix diagram: A grid-like drawing that can be used to discover and record
relationships between entities in an entity-relationship model
Sometimes when you have a lot of entities, its hard to know where to start defining
relationships. What if you miss something? How do you make sure that you havent
missed some combination of entities? Maybe theres a relationship youve missed!
We are going to learn another useful way for identifying relationships.
Slide 4: Tell Me / Show Me Business Scenario:
Demonstrate how to draw a matrix diagram by creating a grid with a diagonal line
running across it and filling top rows and left columns with the names of the entities in
this case, TRAVELER, COUNTRY, and LANDMARK.
Slide 5: Tell Me / Show Me Relationships discovered via the matrix
Point out that after using the matrix diagram, you should draw the relationships on the
ERD to specify optionality and cardinality. Read the ERDish in the completed ERD and
match it with what was listed in the matrix diagram.
Oracle Academy

9
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Note that there are M:M relationships between TRAVELER and COUNTRY, and
between TRAVELER and LANDMARK. Tell them that these are valid relationships, but
they will be discussed more later.
Slide 6: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 7: Summary In this lesson you have learned how to:
No instructor notes for this slide
Slide 8: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

10
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
PRACTICE SOLUTIONS
SECTION 3 Identifying Relationships Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Cardinality/ Degree

A property of an end of a relationship between X and


Y, that describes how many of X is related to Y.

Relationship

A connection or association between objects.

Optionality

A property of an end of a relationship between X and


Y, that describes whether X must be or may be
related to Y.

Try It / Solve It
1. Read the given business scenario. Name the relationships between EMPLOYEE and
JOB. Include appropriate optionality and cardinality.
We have a lot of employees who handle one or more different jobs. Wed like to
keep track of who is working on which job. Although employees can help each
other, a job is assigned to one employee and is the ultimate responsibility of that
individual. All our employees have at least one job. However, there are jobs that
are not yet assigned to anyone.
Solution: Each EMPLOYEE must have (or handle, or be responsible for) one or
more jobs. Each JOB may be the responsibility of (or assigned to) one and only one
EMPLOYEE.
2. Read the given business scenario. Name the relationships between ORDER and
WAITER, including the cardinality and optionality.
We assign our waiters to certain areas, except for our trainees, who just observe
and are not responsible for taking any orders yet. A waiter takes the orders for the
tables in his/her area. All areas have one assigned waiter. A customer places an
order with a waiter. If the customer has a question or wants to make a change to
the order, he/she needs to request this with the assigned waiter.

Oracle Academy

11
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Solution:
Each WAITER may be assigned to (or handle, or take) one or more ORDERs.
Each ORDER must be assigned to (or handled by, or taken by) one and only one
WAITER.
3. Read the given business scenario. Name the relationships between PARENT and
CHILD. Include appropriate optionality and cardinality.
At the end of each day, parents need to pick up their children at our day-care
center. All children must be picked up by 6 p.m. A child may have two parents,
but we need only one of them to come and pick up their child or their children.
We cannot release a child to anyone but that childs parents.
Solution:
Each PARENT may pick up one or more CHILDren.
Each CHILD must be picked up by one and only one PARENT.
4. Read the given business scenario. Name the relationships between TEACHER and
STUDENT. Include appropriate optionality and cardinality.
Some students request remedial help in certain subjects, such as math. We can
assign a tutor who can work with the student after class. Some of our teachers
agree to be tutors. If several students need tutoring in one subject, then we assign
them to the same teacher. If a student needs tutoring in several subjects, then
he/she will probably be assigned to several different tutors.
Solution:
Each TEACHER may tutor one or more STUDENTs.
Each STUDENT may be tutored by one or more TEACHERs.
5. Draw two entities from your own experience (use colored pens and markers on hand).
Write down the relationships between these two entities, including cardinality and
optionality. Share your entities with the class.
Solution: Have the class go through this exercise only if there is extra time.
Verbalizing the diagram demonstrates understanding and creates a desire on the part
of the student to think more deeply about what they are creating because they will be
required to share later. If you do not have time to allow the sharing, you may
want to collect the papers to observe the understanding of each student at this critical
juncture. Presenting is much more public and an easier for which you can provide
feedback.

Oracle Academy

12
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 3 ER Diagramming Conventions Lesson
Vocabulary
Directions: Identify the vocabulary word for the definition below.
A four-sided visual element with rounded corners,
used to represent an entity in an ERD.

Softbox

Try It / Solve It
1. Read the given business scenario. Draw the entities HAIRSTYLIST and CLIENT.
List the attributes associated with each entity and specify whether they are mandatory
or optional. Identify the UIDs. Write out the relationship in English, including
optionality and cardinality. Follow the diagramming conventions discussed.
In our salon, we have a number of hairstylists. They are all salaried employees,
so we keep a record of their first name, last name, address, phone number, socialsecurity number, and salary. During the course of a day, a hairstylist may see
several clients. On a slow day, a hairstylist may not work on anyone at all. We
have several walk-in clients, and they each get assigned to one hairstylist. We just
ask for their first name. We also have customers who call to make an
appointment. When they do this, we ask for their first name, last name, and
phone number. We also ask if they would like a specific hairstylist. If they have
no preference, we assign one for them. Of course, they are allowed to switch to
another hairstylist for their next visit to the salon. We are interested in tracking
the daily appointments which stylist works on which client during a given day.
Solution: In some cases, there could be discussion about whether an attribute is
mandatory or optional. Encourage this discussion and tell students that if it is not
clear in the business scenario, they need to make assumptions. These assumptions
should be documented so you can go back to the client later and confirm them.
HAIRSTYLIST
# id
* first name
* last name
* address
* phone number
* social-security number

Oracle Academy

13
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
CLIENT
#client number
* first name
o last name
o phone number
A HAIRSTYLIST may work on one or more CLIENTs.
A CLIENT must be assigned to one and only one HAIRSTYLIST.
2. Read the given business scenario. Draw the entities BAND and MUSICIAN. List the
attributes underneath each entity. Specify whether they are mandatory or optional.
Identify the UIDs. Write out the relationships in English, including optionality and
cardinality.
I am an agent for several musicians and bands. A musician may be a solo
performer or may belong to a band. A band will always have one or more
musicians in it (some musicians are a one-man band). However, a musician can
belong to only one band. Since I schedule them for concerts and events, I need to
keep track of certain information: the musicians first name, last name, address,
phone number, and hourly rate. If its a band, I need to know the band name in
addition to the information I already keep for the member musicians. Ive handled
bands with the same name, so just to make sure I book the right band, I assign an
ID to each one. The hourly rate for a band is the total of the hourly rates of its
members.
Solution: In some cases, there could be discussion about whether an attribute is
mandatory or optional. Encourage this discussion and tell students that if it is not
clear in the business scenario, they need to make assumptions. These assumptions
should be documented so you can go back to the client later and confirm them.
Why not have hourly rate as an attribute for a band? Answer: because it can be
derived from the hourly rates of the members.
BAND
# band id
* band name
MUSICIAN
# number
* first name
* last name
* address
* phone number
* hourly rate
Oracle Academy

14
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Each BAND must be composed of one or more MUSICIANs.
Each MUSICIAN may belong to one and only one BAND.
3. Read the given business scenario. Draw the entities TEACHER and COURSE and
CLASS. List the attributes under each entity, and specify if they are mandatory or
optional. Identify the UIDs. Write out the relationships in English, including
optionality and cardinality.
We have several teachers at our school. A teacher can be assigned up to three
classes per semester. If a teacher is on sabbatical, he/she doesnt teach that
semester. We keep a record of the teachers first name, last name, address, phone
number, and email address.
Our school offers many courses such as Data Modeling, Introduction to SQL,
Trigonometry, Physics, and Biology. Each course has a code. For example: Data
Modeling would be DM001, Trigonometry would be TR004, etc. During each
semester, a course may be taught in several classes so there could be two classes
of Physics, three classes of Biology, etc. Each class can be taught by only one
teacher. We assign a unique ID for each class, and we also keep track of the day it
is taught, the time, and the classroom.
Solution: The exercise: TEACHER, COURSE, and CLASS deals with three entities.
It is a bit more complicated but can be worthwhile for the faster students. Have them
do this if there is time.
TEACHER
# teacher id
* first name
* last name
* address
* phone number
* email address
COURSE
# code
* description
CLASS
# id
* day
* time
* classroom

Oracle Academy

15
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Each TEACHER may be assigned one or more CLASSes.
Each CLASS must be assigned to one and only one TEACHER.
A COURSE may be offered through one or more CLASSes.
Each CLASS must be an offering for one and only one COURSE.

Oracle Academy

16
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 3 Speaking ERDish and Drawing Relationships Lesson
Vocabulary
Directions: Identify the vocabulary word for the definition below.
ERDish

The language or statements used to describe


relationships between entities in an entityrelationship diagram.

Try It / Solve It
1. The goal of this practice is to read a relationship. Which text corresponds to the
diagram?

a. Each EMPLOYEE may be assigned to one or more DEPARTMENTs.


Each DEPARTMENT must be responsible for one or more EMPLOYEEs.
b. Each EMPLOYEE must be assigned to one and only one DEPARTMENT.
Each DEPARTMENT must be responsible for one or more EMPLOYEEs.
c. Each EMPLOYEE must be assigned to exactly one DEPARTMENT.
Each DEPARTMENT may be responsible for exactly one EMPLOYEE.
Solution: Option b. is the correct reading.
2. In the diagram for #1 identify the symbols for cardinality.
Solution: Crows foot and single toe foot
3. In the diagram for #1 identify the symbols for optionality.
Solution: Solid line (no dotted line exists)

Oracle Academy

17
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
4. Read the relationship in the diagram below. Write the ERD statement for the
relationship.

Solution:
Each camera may be used to take one or more photographs
Each photograph must have been taken with one camera
5. Read each of the relationships in the model below. Write the ERD statement and your
thoughts on each relationship. Use your knowledge of people and towns.

Oracle Academy

18
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Solution:
Each person must be born in one or more towns.
Each town may be birthplace of exactly one person.
Comment: Both sides seem to be of the wrong degree.

Each person must be living in one or more towns.


Each town may be the hometown of one or more persons.
Comment: The first certainly has a wrong degree. The optionality seems wrong
as well.

Each person may be visitor of one or more towns.


Each town must be visited by one or more persons.
Comment: The optionality of the second seems very likely, but is probably
wrong, depending on the definition of town. (Is it possible that a town could be
visited by 0 persons? What if the town was formed yesterday by the government?
Would they have visitors yet? No.

Each person may be mayor of exactly one town.


Each town may be governed by (as mayor) exactly one person.
Comment: Both seem fine, except that if you need to keep historical information,
then both sides of the relationship must be many. Historical information is that
which is tracked as it changes over time. In this case, a person may be mayor of
one town this year, then of another town the next year. Although a town can have
only one mayor at one time, it has different mayors over the years.

Oracle Academy

19
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 3 Matrix Diagrams Lesson
Vocabulary
Directions: Identify the vocabulary word for the definition below.
1.

A grid-like drawing that can be used to discover and


record relationships between entities in an entityrelationship model

Matrix

Try It / Solve It
1. Read the business scenario and review the ERD. Using the matrix diagram, make up
two or more possible relationships between PHOTOGRAPH and the other entities
that make sense for the business.

I am an amateur photographer. I own several cameras and am always taking


pictures of different subjects. I am trying to keep track of which camera and type
of film perform best under certain conditions indoor light, outdoor light, etc. So
when I have my films developed, I note down which camera I used. When the
pictures come back, I note the subject and conditions. Each picture always
features one subject. A subject could be a view, a person or group of persons, or
an object or group of objects.
CAMERA

PHOTOGRAPH

SUBJECT

CAMERA
PHOTOGRAPH
SUBJECT
Oracle Academy

20
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide

Solution:
The extra relationships could be Camera to Photograph
A CAMERA may record one or more PHOTOGRAPHS
A PHOTOGRAPH must be recorded by a CAMERA
Photograph to Subject
A SUBJECT may be captured in a PHOTOGRAPH
A PHOTOGRAPH may capture a SUBJECT
2. Given the matrix diagram below, construct an ERD.
*************** Cross Country
Runner
Cross Country
**************
Runner
City For Race

City For Race

Race Type

************

Race Type

***************

Solution:
*************** Runner

Runner

City For
Race

*********

City For Race

*********

Oracle Academy

Participates In

Running
Event
Run By

Race Type
Running Event

Race Type

The Location
Of

Held In
**********

Of a

Used In

*********

21
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
RUNNER
CITY FOR RACE
Participates
in

The location of

Held in

Run by

RUNNING
EVENT

RACE TYPE
of a

Oracle Academy

Used in

22
Database Design
Copyright 2011, Oracle. All rights reserved.

Supertypes and Subtypes

Copyright 2011, Oracle. All rights reserved.

Supertypes and Subtypes

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define and give an example of a subtype
Define and give an example of a supertype
State the rules relating to entities and subtypes; give
examples of each
Apply the rules of supertype and subtype by evaluating
the accuracy of ER diagrams that represent them
Apply the rules of supertype and subtype and include
them in a diagram when appropriate

Copyright 2011, Oracle. All rights reserved.

Supertypes and Subtypes

Why Learn It?


Purpose
Supertypes and subtypes occur frequently in the real
world -- food orders (eat in, to go), grocery bags (paper,
plastic), payment type (check, cash, credit). You can
typically associate choices of something with
supertypes and subtypes. For example, what do you
like on your sandwich (mustard, mayonnaise, ketchup,
onions, tomatoes, sprouts, cucumbers, lettuce, other).
Understanding real world examples helps us
understand how and when to model them.

Copyright 2011, Oracle. All rights reserved.

Supertypes and Subtypes

Tell Me / Show Me
Evaluating Entities
Often some instances of an entity have attributes
and/or relationships which other instances do not
have.
Imagine a business which needs to track
payments from customers. Customers can pay
by cash, by check or by credit card.
All payments have some common attributes:
payment date, payment amount and so on. But
only credit cards would have a card number
attribute.

PAYMENT
CASH

CHECK

CREDIT CARD

And for credit card and check payments we may


need to know which CUSTOMER made the
payment, while this is not needed for cash
payments.
Should we create a single PAYMENT entity or
three separate entities CASH, CHECK, and
CREDIT CARD? And what happens if in the
future we introduce a fourth method of payment?
Copyright 2011, Oracle. All rights reserved.

Supertypes and Subtypes

Tell Me / Show Me
Subdivide an Entity

Sometimes it makes sense to subdivide an entity


into subtypes. This may be the case when a
group of instances has special properties, such
as attributes or relationships that exist only for
that group. In this case, the entity is called a
"supertype" and each group is called a subtype.

ANIMAL
VERTEBRATE
INVERTEBRATE

A subtype:

inherits all attributes of the supertype


inherits all relationships of the supertype
usually has its own attributes or relationships
is drawn within the supertype
never exists alone
may have subtypes of its own
is also known as a "subentity

ANIMAL SUPERTYPE

Invertebrates are animals with no backbone


(such as earth worms). Vertebrates have
backbone and can be subdivided into birds,
mammals, and reptiles etc.
Copyright 2011, Oracle. All rights reserved.

Supertypes and Subtypes

Tell Me / Show Me
Supertype Example
EXAM is a supertype of
QUIZ, MIDTERM, and
FINAL.

STUDENT

EXAM
# number
* description
* weight
* date
*grade for written component

take

taken by

The subtypes have


several attributes in
common. These common
attributes are listed at the
supertype level. The same
applies to relationships.
Subtypes inherit all
attributes and
relationships of the
supertype entity.

MIDTERM
* grade for oral presentation

BONUS
QUESTION

included in

FINAL
* extra points for
optional paper

QUIZ
includes

EXAM SUPERTYPE
Copyright 2011, Oracle. All rights reserved.

Supertypes and Subtypes

Tell Me / Show Me
Always More Than One Subtype
When an ER model is complete,
subtypes never stand alone. In other
words, if an entity has a subtype, there
should always be at least a second
subtype. This makes sense. What use
would there be for distinguishing
between an entity and the single
subtype? This idea leads to the two
subtype rules:
Exhaustive: Every instance of the
supertype is also an instance of one of
the subtypes.
Mutually Exclusive: Every instance of
the supertype is of one and only one
subtype.

WALL COVERING

PAINT

WALLPAPER
FABRIC

OTHER

WALLCOVERING SUPERTYPE
At the conceptual modeling stage, it is
good practice to include an OTHER subtype to
make sure that your subtypes are exhaustive
-- that you are handling every instance of the
supertype.

Copyright 2011, Oracle. All rights reserved.

Supertypes and Subtypes

Tell Me / Show Me
Subtypes Always Exist
Every entity can always be
subtyped. You can always make
up a rule to subdivide the
instances in groups.

WALL COVERING

PAINT

WALLPAPER
FABRIC

But that is not the issue. The


reason for subtyping should
always be that there is a business
need to show similarities and
differences at the same time.

OTHER

WALLCOVERING SUPERTYPE

Copyright 2011, Oracle. All rights reserved.

Supertypes and Subtypes

Tell Me / Show Me
Correctly Identifying Subtypes
When considering supertypes and
subtypes, you can use three questions
to see if the subtype is correctly
identified:
(1) Is this subtype a kind of supertype?
(2) Have I covered all possible cases?
(exhaustive)
(3) Does the example fit into one and
only one subtype? (mutually
exclusive)

Copyright 2011, Oracle. All rights reserved.

SNOWSPORT

SKI

SNOWBOARD
CROSS COUNTRY

OTHER

Supertypes and Subtypes

Tell Me / Show Me
Nested Subtypes
You can nest subtypes. For
ease of reading -readability -- you would
usually show subtypes with
only two levels, but there is no
rule that would stop you from
going beyond two levels.

ANIMAL
VERTEBRATE
BIRD

REPTILE

MAMMAL

OTHER

INVERTEBRATE

NESTED ANIMAL SUPERTYPE

Copyright 2011, Oracle. All rights reserved.

10

Supertypes and Subtypes

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Subtype / Subentity
Supertype
Exhaustive
Mutually Exclusive

Copyright 2011, Oracle. All rights reserved.

11

Supertypes and Subtypes

Summary
Objectives Summarized
In this lesson, you have learned how to:
Define and give an example of a subtype
Define and give an example of a supertype
State the rules relating to entities and subtypes, and
give examples of each
Apply the rules of supertype and subtype by evaluating
the accuracy of ER diagrams that represent them
Apply the rules of supertype and subtype and include
them in a diagram when appropriate

Copyright 2011, Oracle. All rights reserved.

12

Supertypes and Subtypes

Summary
Practice Guide
The link for the lesson practice guide can be found in
the course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

13

Documenting Business Rules

Copyright 2011, Oracle. All rights reserved.

Documenting Business Rules

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define and compose a structural business rule
Define and compose a procedural business rule
Recognize that some business rules will require
programming
Diagram business rules when they can be represented
in an ER model

Copyright 2011, Oracle. All rights reserved.

Documenting Business Rules

Why Learn It?


Purpose
One of the primary goals of data modeling is to ensure that
all pieces of information that are required to run a business
are recognized.
Identifying and documenting business rules are keys to
checking your data model for accuracy and completeness.
It is important to recognize that not all business rules can be
represented in the ERD. Some business rules must be
implemented by programming.

Copyright 2011, Oracle. All rights reserved.

Documenting Business Rules

Why Learn It?


Identify This Business

Copyright 2011, Oracle. All rights reserved.

Documenting Business Rules

Tell Me / Show Me
Structural and Procedural Business Rules
Structural business rules indicate the types of information
to be stored and how the information elements interrelate.
Procedural rules are workflow or business process
related.
Structural business rules can nearly always be
diagrammed in the ERD. Some procedural business rules
cannot be diagrammed, but must still be documented.
Many procedural business rules are related to time: event
A must happen before event B.

Copyright 2011, Oracle. All rights reserved.

Documenting Business Rules

Tell Me / Show Me
Structural Rule Example
Structural business rules indicate
the types of information to be
stored and how the information
elements interrelate. Here are a
few examples:

All orders at a restaurant must be


handled by a staff member
(specifically, an order taker).
There is no self-service ordering
system.
All teachers at our school must
possess a valid teaching
certificate.

handled by

ORDER

handle

STAFF

TEACHER
# id
* name
* address
teaching certificate
number

Structural Business Rules

Copyright 2011, Oracle. All rights reserved.

Documenting Business Rules

Tell Me / Show Me
Rule Discussion
What kinds of rules does a employer have that affect you?

Each shift I work must be documented on a time card.


Each shift must be supervised by a manager.

Our school has many business rules:

Is it reasonable/effective for a class not to have a teacher


assigned?
Is it reasonable/effective for two students to have the same
student id number or no student id number at all?
Is it reasonable to schedule a teacher to teach a class if no
students are enrolled?
Is it reasonable to allow students to come to school if they
are not enrolled in any (one or more) classes?

Copyright 2011, Oracle. All rights reserved.

Documenting Business Rules

Tell Me / Show Me
Procedural Rule Example
Procedural business rules are workflow or
process related. Here are some examples:

Initial contact with the client from DJs on


Demand must be made by the project
manager.

sdm_s04_l04_a01

Approval for travel requests to an event


must be signed by the project manager for
that event.

Copyright 2011, Oracle. All rights reserved.

Documenting Business Rules

Tell Me / Show Me
Diagram Discussion
Students must have studied algebra and geometry in
order to sign up for trigonometry. Could you represent
this in the ERD?
How would you implement this with programming?
If the student had taken the subjects, can you think of
an additional business rule that a school may want in
this scenario?

Copyright 2011, Oracle. All rights reserved.

Documenting Business Rules

Tell Me / Show Me
Documenting Rules
In the process of developing a conceptual data
model, not all business rules can be modeled.
Some rules such as the two listed below must
be implemented by programming as processes
that interact with data:
sdm_s04_l04_a02

(1) any employee whose overtime exceeds 10


hours per week must be paid 1.5 times the
hourly rate
(2) customers whose account balances are 90
days overdue will not be permitted to charge
additional orders

Copyright 2011, Oracle. All rights reserved.

10

Documenting Business Rules

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Business rule
Procedural business rule
Structural business rule

Copyright 2011, Oracle. All rights reserved.

11

Documenting Business Rules

Summary
Objectives Summarized
In this lesson, you have learned how to:
Define and compose a structural business rule
Define and compose a procedural business rule
Recognize that some business rules will require
programming
Diagram business rules when they can be
represented in an ER model

Copyright 2011, Oracle. All rights reserved.

12

Documenting Business Rules

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

13

Oracle Academy
Database Design
Instructor Resource Guide
INSTRUCTOR NOTES
SECTION 4 Supertypes and Subtypes Lesson
Slide 1: Supertypes and Subtypes
Connections
Review the complete ERD for the DJ business. Point out the subtypes for EMPLOYEE.
Slide 2: What Will I Learn?
No instructor notes for this slide
Slide 3: Why Learn It?
No instructor notes for this slide
Slide 4: Tell Me / Show Me Evaluating Entities
No instructor notes for this slide
Slide 5: Tell Me / Show Me Subdivide an Entity
Subtype/ Subentity: Something an entity may be split into based on common attributes
and/or relationships
Supertype: A means of classifying an entity that has subtypes
Slide 6: Tell Me / Show Me Supertype Example
Read the diagram as:
Every QUIZ, MIDTERM, or FINAL is an EXAM
(and thus has attributes such as description, weight, grade, and date).
Conversely:
Every EXAM is either a QUIZ, a MIDTERM, or a FINAL.
Slide 7: Tell Me / Show Me Always More Than One Subtype
Exhaustive: Treating all parts or aspects without omission.
Mutually exclusive: A relationship that presents choices which are unable to be true at
the same time
Slide 8: Tell Me / Show Me Subtypes Always Exist
No instructor notes for this slide
Slide 9: Tell Me / Show Me Correctly Identifying Subtypes
No instructor notes for this slide
Slide 10: Tell Me / Show Me Nested Subtypes
No instructor notes for this slide

Oracle Academy

1
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
Slide 11: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 12: Summary Objectives Summarized
No instructor notes for this slide
Slide 13: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

2
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 4 Documenting Business Rules Lesson
Slide 1: Documenting Business Rules
No instructor notes for this slide
Slide 2: What Will I Learn?- Objectives
No instructor notes for this slide
Slide 3: Why Learn It?- Identify This Business
Implemented by programming means that once the database is created, a programmer
would write code that would enforce a business rule.
Slide 4: Why Learn It?- Purpose
Implemented by programming means that once the database is created, a programmer
would write code that would enforce a business rule.
Slide 5: Tell Me / Show Me Structural and Procedural Business Rules
Business rule: A formalized statement of the usual, customary, or generalized course of
action or behavior for a business
Structural business rule: A structural business rule indicates the types of information to
be stored and how the information elements interrelate
Procedural business rule: A business rule that is workflow or business process related.
(e.g., A has to happen before B, and then C has to happen at the same time as D.) This is
also called a process business rule
Slide 6: Tell Me / Show Me Structural Rule Example
No instructor notes for this slide
Slide 7: Tell Me / Show Me Rule Discussion
No instructor notes for this slide
Slide 8: Tell Me / Show Me Procedural Rule Example
Ask students the question:
What procedural business rule is evident from the animation?
Answer:
The project manager first works with the client to confirm the event. Then he assigns an
event manager and a DJ to the event.
Discussion:
How do you represent this in the ER diagram? Can you?
Answer:
No, this is a rule that will have to be implemented by a computer program. Visualize a
system where the partners can look up events and update them. The program could allow
only the project manager to enter a new event and then assign the partners who will be
working on it. Once the assignment is made, the system could send out an email
Oracle Academy

3
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
notification to the event manager and the DJ, giving them details about the event, the
customer contact information, etc.
Slide 9: Tell Me / Show Me Diagram Discussion
Could you represent this in the ERD? Answer: No.
How would you implement this with programming? Answer: When a student tries to
sign up online for the trigonometry class, a piece of code would check to see if that
student had taken algebra and geometry.
If the student had taken the subjects, can you think of an additional business rule that a
school may want in this scenario? Answer: Student achieved a passing grade.
Slide 10: Tell Me / Show Me Documenting Rules
Discussion: Why would you document this? Why would you document anything?
Answers include: What if you leave the project? What if you dont implement the
database? The person who does implement the database will discover that the physical
model may not address all the needs of the business because of situations like this!
Important: most procedural rules will be implemented in the physical model by database
check constraints, triggers or privileges, or by application code. In the conceptual
model, the question is: can we draw it in the ERD, or must we document it in words?
Slide 11: Tell Me / Show Me Terminology
No instructor notes for this slide
Slide 12: Summary Objectives Summarized
No instructor notes for this slide
Slide 13: Summary Practice Guide
No instructor notes for this slide

Oracle Academy

4
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
PRACTICE SOLUTIONS
SECTION 4 Supertypes and Subtypes Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Exhaustive

Treating all parts or aspects without omission.

Supertype

A means of classifying an entity that has subtypes.

Subtype/Subentity

Something an entity may be split into based on


common attributes and/or relationships.

Mutually exclusive

A relationship that presents choices that are unable


to be true at the same time.

Try It / Solve It
1. Identify the supertype and subtype of the entity listed below.
DISABILITY
Visual Impairment
Hearing Impairment
Amputation
Paralysis
Solution:
DISABILITY = supertype
Visual Impairment = subtype
Hearing Impairment = subtype
Amputation = subtype
Paralysis = subtype

Oracle Academy

5
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
2. For each rule stated indicate if the rule is applicable to supertypes or subtypes.
__________ They have several attributes in common
__________ They inherit all attributes and relationships of the entity
__________ Never exists alone
__________ Create one when a group of instances of an entity have special properties
Solution:
Subtypes
Subtypes
Subtype
Supertype
3. Name three things you consider when considering supertypes and subtypes.
Solution:
Is this subtype a kind of supertype?
Have I covered all possible cases? (exhaustive)
Does the example fit into one and only one subtype? (mutually exclusive)
4. Find the incorrect subtypes in the illustration. Explain why you think the subtype is
incorrect. Adjust the model to improve it.

Solution: The subtypes for AUTOMOBILE are not mutually exclusive. A 4-DOOR
VEHICLE could also be a SEDAN and/or a SPORT UTILITY VEHICLE.
Suggestion for improvement: remove 4-door vehicle subtype. Consider making
number of doors an attribute of the supertype. Add other nonoverlapping subtypes
or an OTHER subtype.
The subtypes of BUILDING are not exhaustive. Surely there are other BUILDINGs
that are not a HOUSE. Add more subtypes or add an OTHER subtype. Some possible

Oracle Academy

6
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
subtypes of building are OFFICE, SCHOOL, and FACTORY. Ask students to name
other examples of BUILDINGs that could be subtypes.
5. Read the following scenario and construct an ERD that contains at least two subtypes
of the entity PRODUCT. Show clearly which attributes belong to the entity
supertype, and which belong to one of the subtypes. Identify a UID for the entity.
Our shops sell several kinds of womens clothing, including dresses, skirts and
blouses. Of course each product has a name, a description and a price. Oh, and
sizes too: all products have a waist size. Dresses and skirts have a hem length but
blouses dont. Dresses and blouses have a chest size; skirts dont.
Solution: This is tricky because the subtype attributes overlap. For example, hem
length is an attribute of two of the three subtypes (two of four if you include an
OTHER subtype). Either the hem length can be an attribute of both subtypes DRESS
and SKIRT, or hem length can be an attribute of the supertype, with a null value for
instances of BLOUSE.

Oracle Academy

7
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide
SECTION 4 Documenting Business Rules Lesson
Vocabulary
Directions: Identify the vocabulary word for each definition below.
Structural business rule

A structural business rule indicates the types of


information to be stored and how the information
elements interrelate.

Business rule

A formalized statement of the usual, customary, or


generalized course of action or behavior for a
business.

Procedural business rule

A business rule that is workflow or business process


related. (e.g., A has to happen before B, and then C
has to happen at the same time as D.) This is also
called a process business rule.

Try It / Solve It
1. Members of your design team have been working with the local hospital to develop a
data model for their need to store information about patients, the patient's room
number, the patient's doctor, drug prescriptions given, and specific drug information.
However, they all went on vacation and left you to figure out the model. They also
failed to give you any of their documentation other than the entities and attributes
illustrated here. Instead of going back to the hospital, which could reflect poorly on
your company, youre going to have to think about everything you know about
hospitals!
Your task is to generate a list of business rules you think were used to arrive at the
information shown here. Use your imagination. List 10 structural rules, 5 procedural
rules, and 2 programmatic rules (rules to be addressed by computer applications in the
future). State each rule as a single sentence.
Based on your set of business rules, draw the ERD.

Oracle Academy

8
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide

Solution:
Structural Rules:
A patient is someone who is admitted to the hospital.
Each room assignment must include the building number and room number.
Each room may be occupied by one or more patients.
A physician must have a valid license number.
Each drug must be prescribed by a physician.
Each drug prescribed must have a label showing label number, dosage,
treatment duration, and expiration date.
The drug code, name, and cost must be recorded for all drugs.
Each prescription must have a number and date. Each physician may be
assigned to more than one patient. Each patient must have an assigned
physician.
Procedural Rules:
Changes to prescriptions can be made only by licensed physicians.
Patients cannot refill prescriptions without a physician's signature.
Physicians cannot remove drug labels.
Patients cannot change hospital rooms without a physician's recommendation.
Nurses cannot reassign patients without physician approval.
Programming Rules:
Drugs costs are billed at current cost at the time of patient discharge.
Physician fees may reflect additional costs associated with patient
complications, additional patient requests, etc.

Oracle Academy

9
Database Design
Copyright 2011, Oracle. All rights reserved.

Oracle Academy
Database Design
Instructor Resource Guide

Oracle Academy

10
Database Design
Copyright 2011, Oracle. All rights reserved.

Relationship Transferability

Copyright 2011, Oracle. All rights reserved.

Relationship Transferability

What Will I Learn?


Objectives
In this lesson, you will learn to:
Understand the difference between transferable and
nontransferable relationships
Describe and give an example of relationship
nontransferability
Illustrate nontransferable relationships on ERDs

Copyright 2011, Oracle. All rights reserved.

Relationship Transferability

Why Learn It?


Purpose
Once a class has been allocated to a teacher, can that class
later be transferred to another teacher, possibly in midsemester? Usually yes, because if not, what would we do if the
first teacher becomes sick?
Some health clubs allow memberships to be transferred from
one person to another, but other health clubs dont. This
business rule is normally determined by what is most efficient
and most profitable for the club.

Copyright 2011, Oracle. All rights reserved.

Relationship Transferability

Tell Me / Show Me
Relationship Review
Lets review a simple relationship
between SONG and TYPE.
Optionality:
Can you have a TYPE that does
not classify any SONG?
Must every SONG have a TYPE?

SONG
# id
* title
o duration
o artist

classified by
classify

TYPE
# code
* description

SONG and TYPE

Cardinality:
How many SONGs can be
classified under one TYPE?
How many TYPEs can a SONG
have?
Transferability:
Can a SONG be changed from
one TYPE to another TYPE?
Copyright 2011, Oracle. All rights reserved.

Relationship Transferability

Tell Me / Show Me
Nontransferable Relationships
Transferable: A STUDENT being
allowed to move from one STUDY
GROUP to another. There is a
relationship between STUDENT and
STUDY GROUP that is transferable.
Nontransferable: A STUDENT can be
issued a RECEIPT for paying tuition
fees, taking a certification exam, or
purchasing items at the bookstore.
Once a RECEIPT has been issued, it
cannot be transferred to another
STUDENT. If it was issued in error, it
would have to be cancelled, and
another RECEIPT would have to be
written up. The relationship between
STUDENT and RECEIPT is
nontransferable.

STUDENT

STUDY GROUP

join
have

Transferable Relationship

RECEIPT

STUDENT

issued to
issued

Nontransferable Relationship
A nontransferable relationship
is represented with the
diamond on the relationship.

Copyright 2011, Oracle. All rights reserved.

Relationship Transferability

Tell Me / Show Me
More Nontransferable
Relationships
POEM

Ownership of a POEM belongs with


its AUTHOR. Authorship is a
relationship that cannot be moved to
another person.
In the DJ business, an EVENT is
owned by the CLIENT. If there are
questions about outstanding
payments on an EVENT, that
CLIENT cannot transfer
responsibility to another person.
He/she can designate a
representative, but ultimate
ownership still belongs with the
original CLIENT.

AUTHOR

written by

the writer of

EVENT

CLIENT

owned by

Copyright 2011, Oracle. All rights reserved.

the owner of

Relationship Transferability

Tell Me/ Show Me


Terminology:
Key terms in this lesson include:
Transferable
Nontransferable

Copyright 2011, Oracle. All rights reserved.

Relationship Transferability

Summary
Objectives Summarized
In this lesson, you have learned how to:
Understand the difference between transferable and
nontransferable relationships
Describe and give an example of relationship
nontransferability
Illustrate nontransferable relationships on ERDs

Copyright 2011, Oracle. All rights reserved.

Relationship Transferability

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

Relationship Types

Copyright 2011, Oracle. All rights reserved.

Relationship Types

What Will I Learn?


Objectives
In this lesson, you will learn to:
Recognize and give examples of a one-to-one
relationship
Recognize and give examples of a one-to-many
relationship
Recognize and give examples of a many-to-many
relationship
Recognize redundant relationships and remove them
from the ERD

Copyright 2011, Oracle. All rights reserved.

Relationship Types

Why Learn It?


Purpose
Can one PERSON own many DVDs, or only one ?
Can one DVD be owned by many PERSONs?
As we refine and improve our model, we want to make sure
our entity relationships correctly model our business rules.
Remember, you can avoid future costly mistakes by thinking
through the details early on.

Copyright 2011, Oracle. All rights reserved.

Relationship Types

Tell Me / Show Me
One-to-Many (1:M) Relationships
The various types of 1:M
relationships are most common in
an ER Model. You have seen
several examples already.

Relationship Types
1:M

has

DEPARTMENT
work for

EMPLOYEE

1:M Relationship

Copyright 2011, Oracle. All rights reserved.

Relationship Types

Tell Me / Show Me
Many-to-Many (M:M)
Relationships
The various types of M:M
relationships are common,
particularly in a first version of an
ER model. In later stages of the
modeling process, most M:M
relationships, and possibly all, will
disappear.
STUDENT

Relationship Types
M:M

learn from

TEACHER

educate

M:M Relationships

Copyright 2011, Oracle. All rights reserved.

Relationship Types

Tell Me / Show Me
One-to-One
Relationships For
Roles
Usually you will find just
a few of the various
types of 1:1
relationships in every
ER model.

Relationship Types
1:1

acting as

PERSON

Mandatory at one end of


the 1:1 relationship
commonly occurs when
roles are modeled. See
the school model.

TEACHER
role of

acting as

STUDENT
role of

1:1 Relationships

Copyright 2011, Oracle. All rights reserved.

Relationship Types

Tell Me / Show Me
One-to-One
Relationships For
Process
EXAM

1:1 relationships (of


all three variations)
also occur when
some of the entities
represent various
stages in a
process.

evaluated with

ANSWER KEY
for

RECIPE

DISH

the basis for


the result

1:1 Process Relationships

Copyright 2011, Oracle. All rights reserved.

Relationship Types

Tell Me / Show Me
Redundant Relationships

COUNTRY

location of

A redundant relationship can be derived


from another relationship in the model.
hometown
of

located in

TOWN

hometown
of

living in

PERSON

living in

COUNTRY

location of

In the example on the left, you can


derive the relationship from PERSON to
COUNTRY from the other two
relationships, and you should remove
them from the model -- as indicated on
the left.
However, be careful of concluding that
a relationship is redundant based on
the structure alone. Read the
relationships to check. The ERD on the
right does not reflect a redundant
relationship.

Copyright 2011, Oracle. All rights reserved.

the birthplace
located of
in

TOWN

hometown
living

born in

PERSON

Relationship Types

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Many-to-many (M:M)
One-to-many (1:M)
One-to-one (1:1)
Redundant

Copyright 2011, Oracle. All rights reserved.

Relationship Types

Summary
Objectives Summarized
In this lesson, you have learned how to:
Recognize and give examples of a one-to-one
relationship
Recognize and give examples of a one-to-many
relationship
Recognize and give examples of a many-to-many
relationship
Recognize redundant relationships and remove them
from the ERD

Copyright 2011, Oracle. All rights reserved.

10

Relationship Types

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

11

Resolving Many-to-Many Relationships

Copyright 2011, Oracle. All rights reserved.

Resolving Many-to-Many Relationships

What Will I Learn?


Objectives
In this lesson, you will learn to:
Identify attributes which belong to many-to-many
relationships
Demonstrate the steps to resolve a many-to-many
relationship using an intersection entity
Identify the UID of an intersection entity and represent it in
the entity relationship diagram

Copyright 2011, Oracle. All rights reserved.

Resolving Many-to-Many Relationships

Why Learn It?


Purpose
This lesson will help you complete your model -- you may need
to create new entities or new relationships based on the
business needs.
It will also help you define the scope of your data model -- you
only model what is of importance to the business.

Copyright 2011, Oracle. All rights reserved.

Resolving Many-to-Many Relationships

Tell Me / Show Me
Relationship Hiding an Attribute
In the DJ business, each
PARTNER may be assigned to
work on one or more EVENTs.
Each EVENT may be a job for one
or more PARTNERs.
When an EVENT PLANNER, a DJ,
or a PROJECT MANAGER works
on an EVENT, we want them to
record the status of the job.

Which entity would the attribute


"status" belong to?

EVENT and PARTNER


PARTNER
# id
* first name
* last name

EVENT PLANNER
* expertise

DJ
* specialty

work on

worked on
by

EVENT
# id
* name
* date
o description
* cost

MANAGER
o authorized
expense limit

Copyright 2011, Oracle. All rights reserved.

Resolving Many-to-Many Relationships

Tell Me / Show Me
Resolution of a M:M Relationship
A third entity is needed to resolve the M:M relationship.
This is called an "intersection" entity.

sdm_s05_l03_a01

Copyright 2011, Oracle. All rights reserved.

Resolving Many-to-Many Relationships

Tell Me / Show Me
Intersection Entity
An intersection entity
JOB ASSIGNMENT
has been added,
including the status
attribute.
The original M:M
relationship has
become two 1:M
relationships.
What would be the
UID of the
intersection entity?

JOB ASSIGNMENT
o status
for

for

PARTNER
# id
* first name
* last name

EVENT PLANNER
* expertise

responsible
for

the source of

EVENT
# id
* name
* date
o description
* cost

DJ
* specialty

MANAGER
o authorized
expense limit

Copyright 2011, Oracle. All rights reserved.

JOB ASSIGNMENT
6

Resolving Many-to-Many Relationships

Tell Me / Show Me
Barred Relationships
The unique identifier
(UID) of the
intersection entity
often comes from the
originating
relationships and is
represented by the
bars. In this case, the
relationships from the
originating entities to
the intersection entity
are called "barred"
relationships.

JOB ASSIGNMENT
o status

for

PARTNER
# id
* first name
* last name
EVENT PLANNER
* expertise

for

responsible
for

the source of

EVENT
# id
* name
* date
o description
* cost

DJ
* specialty

MANAGER
o authorized
expense limit

Copyright 2011, Oracle. All rights reserved.

JOB ASSIGNMENT

Resolving Many-to-Many Relationships

Tell Me / Show Me
M:M Resolution
Example TV Shows
Each TV show may be
watched by one or more
persons.

TV SHOW
watched by

TV SHOW

PERSON
watch

Each person may watch


one or more TV shows.

Resolution of M:M
for

VIEWING
RECORD

on

TV SHOW

Copyright 2011, Oracle. All rights reserved.

for

on

PERSON

Resolving Many-to-Many Relationships

Tell Me / Show Me
M:M Resolution
Example Cleaning
Services
Each company may
provide one or more
cleaning services.

CLEANING SERVICES
provide

CLEANING
COMPANY

CLEANING
SERVICE

provided by

Resolution of M:M

Each cleaning service


may be provided by one
or more companies.

for

CLEANING
SCHEDULE

on

CLEANING
COMPANY

Copyright 2011, Oracle. All rights reserved.

for

on

CLEANING
SERVICE

Resolving Many-to-Many Relationships

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Barred relationship
Intersection entity

Copyright 2011, Oracle. All rights reserved.

10

Resolving Many-to-Many Relationships

Summary
Objectives Summarized
In this lesson, you have learned how to:
Identify attributes which belong to many-to-many
relationships
Demonstrate the steps to resolve a many-to-many
relationship using an intersection entity
Identify the UID of an intersection entity and represent it
in the entity relationship diagram

Copyright 2011, Oracle. All rights reserved.

11

Resolving Many-to-Many Relationships

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

12

Understanding CRUD Requirements

Copyright 2011, Oracle. All rights reserved.

Understanding CRUD Requirements

What Will I Learn?


Objectives
In this lesson, you will learn to:

Create ER models that reflect all business rules


gathered during the interview process
Identify the create, retrieve, update, and delete (CRUD)
requirements of the business
Validate your ER model by performing a CRUD analysis

Copyright 2011, Oracle. All rights reserved.

Understanding CRUD Requirements

Why Learn It?


Purpose
The ERD is the conversation tool between the consultant and
the client. It is also the guideline for the DBA who will
eventually build the database.
You need a way to check that you havent missed any entities
or relationships in your data model. Its like taking a list of
books to the school book store. You also want to make sure
that you havent modeled anything that the business does not
require. CRUD analysis will help you do this.

Copyright 2011, Oracle. All rights reserved.

Understanding CRUD Requirements

Tell Me / Show Me
CRUD Analysis
A good way to validate an ERD is to do a CRUD analysis on
it. CRUD is an acronym for create, retrieve, update, delete.
These are the four basic operations that a database allows.
Part of checking a data model for completeness and
accuracy is making sure that all the CRUD functions
specified by the business scenario and the business rules
are represented in the ERD.

Copyright 2011, Oracle. All rights reserved.

Understanding CRUD Requirements

Tell Me / Show Me
Create Operation
Keywords to look for in the client interviews, business
scenarios and so on are INPUT, ENTER, LOAD, IMPORT,
RECORD, and CREATE. These all indicate that a record is
created in the database at this time. Review the
requirements for these keywords. Does your data model
account for all these functions?

Copyright 2011, Oracle. All rights reserved.

Understanding CRUD Requirements

Tell Me / Show Me
Retrieve Operation
Keywords to look for are VIEW, REPORT, BRING UP,
PRINT, FIND, READ and LOOK UP. These all point to
retrieving information from the database. Review the
requirements for these keywords. Does your data model
account for all these functions?

Copyright 2011, Oracle. All rights reserved.

Understanding CRUD Requirements

Tell Me / Show Me
Update Operation
Keywords to look for are CHANGE, MODIFY, ALTER and
UPDATE. These all point to updating information that is
already in the database. Review the requirements for these
keywords. Does your data model account for all these
functions?

Copyright 2011, Oracle. All rights reserved.

Understanding CRUD Requirements

Tell Me / Show Me
Delete Operation
Keywords to look for are DISCARD, REMOVE, TRASH,
PURGE and DELETE. These all point to deleting information
that is already in the database. Review the requirements for
these keywords. Does your data model account for all these
functions?

Copyright 2011, Oracle. All rights reserved.

Understanding CRUD Requirements

Tell Me / Show Me
CRUD Validation
Performing a CRUD analysis on your data model helps you
check for scope and completeness:
If you have a business function that has no entity to CRUD
against, then your data model may be incomplete.
Similarly, if you have entities in your ERD that are not
touched by any CRUD (there is no business function that
creates, retrieves, updates, or deletes from it), then you
may not need that entity in your model.

Copyright 2011, Oracle. All rights reserved.

Understanding CRUD Requirements

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Consultant
Functions
CRUD analysis

Copyright 2011, Oracle. All rights reserved.

10

Understanding CRUD Requirements

Summary
Objectives Summarized
In this lesson, you have learned how to:

Create ER models that reflect all business rules gathered


during the interview process
Identify the create, retrieve, update, and delete (CRUD)
requirements of the business
Validate your ER model by performing a CRUD analysis

Copyright 2011, Oracle. All rights reserved.

11

Understanding CRUD Requirements

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

12

Artificial, Composite and Secondary UIDs

Copyright 2011, Oracle. All rights reserved.

Artificial, Composite and Secondary UIDs

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define the different types of unique identifiers (UIDs)
Define a candidate UID and explain why an entity can
sometimes have more than one candidate UID
Analyze business rules and choose the most suitable
primary UID from the candidates
Recognize and discuss the issues of identification in the
real world

Copyright 2010, Oracle. All rights reserved.

Artificial, Composite and Secondary UIDs

Why Learn It?


Purpose
The unique identifier (UID) is very important in relational
databases.
It is the value or combination of values that enables the
user to find that one unique item among all the rest.
Identifying just the right attribute, combination of attributes,
and/or relationships is a skill that any database designer
must master. The unique identifier is the way to find your
record in a file, a particular card in a deck of cards, your
package in a warehouse, and a specific piece of data in a
database.

Copyright 2010, Oracle. All rights reserved.

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
Simple UIDs vs.
Composite UIDs
A UID that is a single
attribute is a simple UID.
However, sometimes a
single attribute is not
enough to uniquely
identify an instance of an
entity. If the UID is a
combination of attributes,
it is called a composite
UID.

DEPARTMENT
# code
* name

CONCERT TICKET
# date of performance
# seat number

Simple Unique
Identifier

Composite Unique
Identifier

Copyright 2010, Oracle. All rights reserved.

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
Artificial UIDs
Artificial UIDs are those that
dont occur in the natural world
but are created for purposes of
identification in a system.
People are not born with
numbers, but a lot of systems
assign unique numbers to
identify people: student numbers,
customer IDs, etc.

SHOE
* color
* size
* style

Create an
artificial UID

SHOE
# shoe ID
* color
* size
* style

A shoe has a color, a size, a


style, but no truly descriptive
number. However, a shoe store
will assign unique numbers to
each pair of shoes so they can
be uniquely identified.
Copyright 2010, Oracle. All rights reserved.

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
Artificial UID Example
How can we uniquely
identify a STUDENT?
Could we use a combination
of first name and last name?
Only if we are sure that the
combination is unique.

STUDENT
* first name
* last name
* address

STUDENT
# student ID
* first name
Create an artificial UID * last name
* address

Often, it is simpler and more


straightforward to create an
artificial attribute and make
it the unique identifier.
A UID can be both artificial
and composite.

Copyright 2010, Oracle. All rights reserved.

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
UIDs from Barred
Relationships
Sometimes the UID is a
combination of an attribute
and a relationship.
What is the UID of
ACCOUNT? Is it artificial?
Is it composite?

ACCOUNT
# number
* balance
* date opened

at

have

BANK
# number
* name
* location

Two people could have the


same bank account number,
but at different banks.
Bank to bank transfers
always need the bank
routing number in addition to
the bank account number.
Copyright 2010, Oracle. All rights reserved.

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
UID from Barred Relationship
Intersection Entity
As weve seen before, the
resolution of a M:M relationship
often results in barred
relationships from the
intersection entity to the original
ones.

PLAY LIST ITEM


o comments

for

for

have

In this example, the UID of PLAY


LIST ITEM comes from EVENT
and SONG. The bars on the
relationships tell you this.

EVENT
# id
* cost
* name
* date
o description

Copyright 2010, Oracle. All rights reserved.

on
SONG
# id
* title
o artist
o duration

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
Artificial UID Intersection Entity
It is possible for an intersection entity to
use an artificial attribute as the UID,
instead of the barred relationships to
the originating entities.
Each MANUFACTURER may produce
one or more PRODUCTs (shoes,
shirts, jeans, etc.). Each PRODUCT
may be produced by one or more
MANUFACTURERs (Nike shoes,
Adidas shoes, Levis jeans, etc.).

CATALOG ITEM
# number
* price

MANUFACTURER
# number
* name

PRODUCT
# code
* description

CATALOG ITEM resolves this many-to-many relationship. An item in a


catalog can be uniquely identified by the manufacturer number and the
product code. The relationships are not barred, because an artificial UID
catalog number has been created instead.
Copyright 2010, Oracle. All rights reserved.

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
Candidate UIDs
Sometimes there is more than one possible UID.

For example, when you order a product from a commercial


website, you will usually be assigned a unique customer
code and also asked to enter your e-mail address.
Each of these uniquely identifies you, and each could be
chosen as the UID. These are both candidate UIDs.
Only one of the candidate UIDs is chosen as the actual UID.
This is called the primary UID. The other candidates are
called secondary UIDs.

Copyright 2010, Oracle. All rights reserved.

10

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
Candidate UIDs (continued)
Student ID has been chosen as the
primary UID in both of these STUDENT
entities.
The first entity has one secondary UID,
while the second has two secondary UIDs
(one of which is composite).

STUDENT
# student ID
(#) badge number
* first name
* last name
* address
One Primary UID
One Secondary UID

STUDENT
# student ID
(#1) badge number
(#2-1) first name
(#2-2) last name
* address
One Primary UID
Two Secondary UIDs

Copyright 2010, Oracle. All rights reserved.

11

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
Identification: Database vs. Real
World
Unique identifiers make it possible
for us to distinguish one instance of
an entity from another. As you will
see later, these become primary
keys in the database. A primary key
allows you to access a specific
record in a database.

sdm_s07_l02_a01

In the real world, however, it is


sometimes not so easy to
distinguish one thing from another.
Copyright 2010, Oracle. All rights reserved.

12

Artificial, Composite and Secondary UIDs

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Artificial UID
Candidate UID
Composite UID
Primary UID
Secondary UID
Simple UID
UID

Copyright 2010, Oracle. All rights reserved.

13

Artificial, Composite and Secondary UIDs

Summary
Objectives Summarized
In this lesson, you have learned how to:
Define the different types of unique identifiers (UIDs)
Define a candidate UID and explain why an entity can
sometimes have more than one candidate UID
Analyze business rules and choose the most suitable
primary UID from the candidates
Recognize and discuss the issues of identification in the
real world

Copyright 2010, Oracle. All rights reserved.

14

Artificial, Composite and Secondary UIDs

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course outline.

Copyright 2010, Oracle. All rights reserved.

15

Normalization and First Normal Form

Copyright 2011, Oracle. All rights reserved.

Normalization and First Normal Form

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define the purpose of normalization in database models
Define the rule of First Normal Form in the normalization
process
Determine if an entity conforms to the rule of First Normal
Form
Convert an entity to First Normal Form if needed

Copyright 2010, Oracle. All rights reserved.

Normalization and First Normal Form

Why Learn It?


Purpose
Think about storing your friends phone numbers in three different places:
your address book, your cell phone, and a sheet of paper that you have
taped to your refrigerator. Its a lot of work if a friend changes his/her phone
number. You have to change it in your address book, cell phone, and the
sheet of paper taped to your refrigerator.

What happens if data is stored in more than one place in a database? What
if someone changes the information in one place and not the other? How do
you know which information is correct?
Normalization is a process to eliminate these kinds of problems.

Your goal as a database designer is to "store information in one


place and the best place. Following the rules of normalization helps
you achieve this goal.
Copyright 2010, Oracle. All rights reserved.

Normalization and First Normal Form

Tell Me / Show Me
First Normal Form (1NF)
First Normal Form requires that there
be no multivalued attributes.
To check for 1NF, validate that each
attribute has a single value for each
instance of the entity.
There are many classrooms in a
school building, so it is a repeating
attribute. This is a violation of 1NF.
If an attribute has repeating values,
create an additional entity and relate it
to the original entity with a M:1
relationship.

SCHOOL BUILDING 1NF


SCHOOL BUILDING
# code
* name
* address
o classroom

The classroom attribute


will have multiple values.
This entity is not in First
Normal Form.

SCHOOL BUILDING the location


of
# code
* name
located
* address
in

CLASSROOM
# number
* floor
* size

CLASSROOM is now its own entity.


All attributes have only one value per instance.
Both entities are in First Normal Form.

Copyright 2010, Oracle. All rights reserved.

Normalization and First Normal Form

Tell Me / Show Me
1NF Violations
Examine the entities on the right.
Are there any multivalued
attributes?

CLIENT
# number
* first name
* last name
o event

1)

2)

3)

TEAM
# id
* name
* player

SHOPPING
MALL
# id
* name
* address
* store name
* store floor

belong to
made up of

LEAGUE
# number
* name

1NF Violations
Copyright 2010, Oracle. All rights reserved.

Normalization and First Normal Form

Tell Me / Show Me
1)

1NF Solutions
When all the attributes in
an entity are singlevalued, that entity is said
to be in First Normal
Form.

2)

3)

EVENT
# id
* name

belong to
own

STORE
# name
* floor

located in
house

TEAM
# id
* name
* player

CLIENT
# number
* first name
* last name
* event
SHOPPING
MALL
# id
* name
* address
store name
store floor

belong to
made up of

have
belong to
PLAYER
# number
* name
o position

LEAGUE
# number
* name

1NF Solutions

Copyright 2010, Oracle. All rights reserved.

Normalization and First Normal Form

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Normalization
First Normal Form (1NF)
Redundancy

Copyright 2010, Oracle. All rights reserved.

Normalization and First Normal Form

Summary
Objectives Summarized
In this lesson, you have learned how to:
Define the purpose of normalization in database
models
Define the rule of First Normal Form in the
normalization process
Determine if an entity conforms to the rule of First
Normal Form
Convert an entity to First Normal Form if needed

Copyright 2010, Oracle. All rights reserved.

Normalization and First Normal Form

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

Second Normal Form

Copyright 2011, Oracle. All rights reserved.

Second Normal Form

What Will I Learn?


Objectives
In this lesson, you will learn how to:
Define the rule of Second Normal Form in the
normalization process
Examine a nonnormalized entity and determine which
rule (or rules) of normalization are being violated
Apply the rule of Second Normal Form to resolve a
violation in the model

Copyright 2011, Oracle. All rights reserved.

Second Normal Form

Why Learn It?


Purpose
Your goal as a database designer is to store information in
one place and the best place.
Following the rules of normalization helps you achieve this
goal.

When organizing information such as your friends phone


numbers and addresses, you want to make sure that you
store it in the appropriate place -- such as a personal
address book. If you store a friends address in your recipe
box, for instance, you may not find it until the next time you
look up that recipe.
Normalization is a process to eliminate these kinds of
problems.
Copyright 2011, Oracle. All rights reserved.

Second Normal Form

Tell Me / Show Me
Second Normal Form Example
Examine the entity PRODUCT
SUPPLIER. The UID is a combination of
Supplier number and Product number.
What about the Supplier Name attribute?
If one supplier supplies 5 different
products, what happens if the supplier
name changes ?

PRODUCT SUPPLIER

# supplier number
# product number
* purchase price
* supplier name

The name would need to be changed in 5


instances of the entity. What if some of
them were changed, but not others? What
would be the correct value for the supplier
name?
Copyright 2011, Oracle. All rights reserved.

Second Normal Form

Tell Me / Show Me
Second Normal Form Description
Second Normal Form requires that any non-UID attribute
be dependent on the entire UID.
This means that all attributes that are not part of the
entitys UID should be dependent on the whole UID. This
specifically applies to entities that have a UID that is
composed of more than one attribute or a combination of
attribute(s) and relationship(s).

Copyright 2011, Oracle. All rights reserved.

Second Normal Form

Tell Me / Show Me
Second Normal Form Bar Relationship
The same ACCOUNT numbers exist at different BANKs so
the relationship is part of the UID. This is represented by the
bar on the relationship.

ACCOUNT
# number
* balance
* date opened

located in
the location
for

BANK
# number
* name

Copyright 2011, Oracle. All rights reserved.

Second Normal Form

Tell Me / Show Me
Second Normal Form
Violation
In this ERD, however, the
attribute bank location is
misplaced. It depends ONLY
on the BANK number.

ACCOUNT
# number
* balance
* date opened
* bank location

BANK
# number
* name

This is a violation of Second


Normal Form.
What would happen if a banks
location changed? All the
accounts at that bank would
need to be changed.
Copyright 2011, Oracle. All rights reserved.

Second Normal Form

Tell Me / Show Me
Second Normal Form Song Example

The DJ is responsible for preparing the collection of


songs to be played at each event. Each SONG can
be played at more than one EVENT, and each
EVENT will use more than one SONG. Lets look at
how the DJ prepares the play list.

Copyright 2011, Oracle. All rights reserved.

Second Normal Form

Tell Me / Show Me
Modified DJ ERD
What is wrong with this
diagram?
Answer: The attributes
duration and event date
are misplaced. Duration
depends solely on SONG,
and event date depends
solely on EVENT.

PLAY LIST ITEM


o comments
o duration
* event date

EVENT
# id
* cost
* name
o description

SONG
# id
* title
o artist

This is a violation of
Second Normal Form.

Copyright 2011, Oracle. All rights reserved.

Second Normal Form

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Second Normal Form (2NF)

Copyright 2011, Oracle. All rights reserved.

10

Second Normal Form

Summary
Objectives Summarized
In this lesson, you have learned how to:
Define the rule of Second Normal Form in the
normalization process
Examine a nonnormalized entity and determine which
rule (or rules) of normalization are being violated
Apply the rule of Second Normal Form to resolve a
violation in the model

Copyright 2011, Oracle. All rights reserved.

11

Second Normal Form

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

12

Third Normal Form

Copyright 2011, Oracle. All rights reserved.

Third Normal Form

What Will I Learn?


Objectives
In this lesson, you will learn to:
Identify transitive dependencies in a data model
Define the rule of Third Normal Form in the
normalization process
Examine a non-normalized entity and determine which
rule (or rules) of normalization are being violated
Apply the rule of Third Normal Form to resolve a
violation in the model

Copyright 2011, Oracle. All rights reserved.

Third Normal Form

Why Learn It?


Purpose
Your goal as a database designer is to "store information in one place and
the best place." Following the rules of normalization helps you achieve this
goal.
You may want to enter different kinds of information for a friend in your
personal address book: phone number, address, name of school or place of
work. If you have several friends who go to the same school, and you enter
the schools street address along with each of them, you would not only be
duplicating data but causing potential problems -- for instance, if the school
moved and changed its address, you would have to go back and change it
everywhere!
Normalization is a process to eliminate these kinds of problems.

Copyright 2011, Oracle. All rights reserved.

Third Normal Form

Tell Me / Show Me
Third Normal Form Rule
The rule of Third Normal Form (3NF) states that no
non-UID attribute can be dependent on another
non-UID attribute.

Third Normal Form prohibits transitive


dependencies. A transitive dependency exists when
any attribute in an entity is dependent on any other
non-UID attribute in that entity.

Third Normal
Form Violation

CD
# id
* title
* producer
* year
o store name
o store address

Think of the kind of information you'd like to store


about your CD collection. Does information about
the store where you bought the CD belong in the
same entity?
If the store address changed, you would have to
change the information on all the CDs that were
bought at that store.

Copyright 2011, Oracle. All rights reserved.

Third Normal Form

Tell Me / Show Me
Third Normal Form Transitive
Dependency
The store address is dependent on the
CD number, which is the UID of the CD
entity. So this entity is in 1NF and 2NF.
But store address is also dependent on
store name, which is a non-UID
attribute.
This is an example of a transitive
dependency and a violation of Third
Normal Form.
The correctly normalized model is
shown here: create a second entity
STORE, with a relationship to CD.

Third Normal
Form Violation

CD
# id
* title
* producer
* year

CD
# id
* title
* producer
* year
o store name
o store address

contained in
contains

STORE
# number
* name
* address

Third Normal
Form

Copyright 2011, Oracle. All rights reserved.

Third Normal Form

Tell Me / Show Me
Third Normal Form
Example

Third Normal
Form Violation

Consider a system that


tracks information about
cities -- size, population,
mayor, and so on.
The first model shows an
entity that includes state
information. Although state
is an attribute of city, state
flower is really an attribute of
state.
The second model, with a
new entity STATE, is in
Third Normal Form.

CITY
# id
* name
* size
* population
* mayor
* state
* state flower

Third Normal
Form

CITY
# id
* name
* size
* population
* mayor

Copyright 2011, Oracle. All rights reserved.

in
have

STATE
# id
* name
* flower

Third Normal Form

Tell Me / Show Me
Third Normal Form Second
Example
In this example, assume the
following business rule: each
employee can have one
partner.

EMPLOYEE
# id
* name
* address
* birth place
o partner name
o partner birth date

This model violates Third


Normal Form because partner
birth date is an attribute of
partner, not of EMPLOYEE.

part of
composed
of

DEPARTMENT
# number
* name
* budget

Third Normal
Form Violation

Another way of stating Third


Normal Form: non-UID
attributes cant have attributes
of their own.

Copyright 2011, Oracle. All rights reserved.

Third Normal Form

Tell Me / Show Me
3NF Second Example
Solution
This model supports Third
Normal Form because partner
birth date is an attribute of
partner, not of EMPLOYEE.

EMPLOYEE
# id
* name
* address
* birth place

part of

DEPARTMENT
# number
* name
composed
* budget
of

have

The 1:1 relationship is optional


on the EMPLOYEE end
because some employees will
not have partners. It is
mandatory on the PARTNER
end because information about
a partner is tracked only if that
person is a partner of one and
only one EMPLOYEE.

the dependent of
PARTNER
# name
* birth date

Copyright 2011, Oracle. All rights reserved.

Third Normal
Form

Third Normal Form

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Third Normal Form (3NF)
Transitive dependency

Copyright 2011, Oracle. All rights reserved.

Third Normal Form

Summary
Objectives Summarized
In this lesson, you have learned how to:
Identify transitive dependencies in a data model
Define the rule of Third Normal Form in the normalization
process
Examine a nonnormalized entity and determine which rule
(or rules) of normalization are being violated
Apply the rule of Third Normal Form to resolve a violation
in the model

Copyright 2011, Oracle. All rights reserved.

10

Third Normal Form

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2011, Oracle. All rights reserved.

11

Arcs

Copyright 2011, Oracle. All rights reserved.

Arcs

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define the term "constraint" as it applies to data
modeling
Identify an exclusive OR relationship in a business
scenario
Diagram an arc constraint to represent an exclusive OR
relationship
Distinguish between the use of an arc and a subtype in
the data model

Copyright 2010, Oracle. All rights reserved.

Arcs

Why Learn It?


Purpose
Arcs in data modeling help designers clarify an exclusive
OR across relationships. The more explicitly you can define
the client's requirements, the more accurate your final
implementation will be.

Copyright 2010, Oracle. All rights reserved.

Arcs

Tell Me / Show Me
What is a Constraint?
Every business has restrictions on which attribute
values and which relationships are allowed.
These restrictions are called constraints. They may
refer to a single attribute of an entity, or to
relationships between entities.
We already know about several kinds of constraint,
for example: every EMPLOYEE must work in one
and only one DEPARTMENT.
In this lesson we will see another kind of constraint:
an exclusive OR constraint.

Copyright 2010, Oracle. All rights reserved.

Arcs

Tell Me / Show Me
Exclusive OR
Relationships
Mutually exclusive
relationships (sometimes
called exclusive OR
relationships) often exist.
For example:
A billboard is an advertising
space that can feature a
movie, a product, or a
public announcement. It
may contain advertising
about only one of these at a
time. Each feature has its
own characteristics or
attributes.

BILLBOARD
# number
* size
* location

feature
featured
on

feature

feature

Copyright 2010, Oracle. All rights reserved.

MOVIE
# title
o opening date

PRODUCT
ADVERTISEMENT
featured # name
on

PUBLIC
ANNOUNCEMENT
featured # message
on

Arcs

Tell Me / Show Me
DJs on Demand Business Scenario
The DJ business has a mutually
exclusive relationship between EVENT
and VENUE.

sdm_s07_l03_a01

Copyright 2010, Oracle. All rights reserved.

Arcs

Tell Me / Show Me
Representing Exclusive
OR Relationships in the
ERD
Arcs are a way to represent
mutually exclusive
relationships in the ERD.
The arc represents the
exclusive OR relationship -each EVENT must be held
at one PRIVATE HOME or
must be held at one PUBLIC
SPACE, but not both.

EVENT
# id
* cost
* name
* date
o description

held at

the venue for


PRIVATE HOME
# id
* address
o comments

Copyright 2010, Oracle. All rights reserved.

held at

the venue for


PUBLIC SPACE
# id
* address
* rental fee
o comments

Arcs

Tell Me / Show Me
Arcs
An arc always belongs to one
entity.
Arcs can include more than two
relationships.
Not all relationships of an entity
need to be included in an arc.
An entity may have several arcs.
An arc should always consist of
relationships of the same
optionality:
All relationships in an arc must
be mandatory or all must be
optional.
Relationships in an arc may be
of different degree, although
this is rare.

USER

LIST

is referred to
container of

referring
to

contained in

is
referred
to

referring
to

LIST ITEM

Copyright 2010, Oracle. All rights reserved.

Arcs

Tell Me / Show Me
Arcs (continued)
Examine the following example.

Copyright 2010, Oracle. All rights reserved.

Arcs

Tell Me / Show Me
EVENT
# id
* cost
* name
* date
o description

Arcs, Supertypes, and Subtypes


Arcs can sometimes be drawn as
supertypes or subtypes.

held at

the venue for

VENUE
# id
* address
o comments

PRIVATE HOME
o accessibility
feature?

Copyright 2010, Oracle. All rights reserved.

PUBLIC SPACE
* rental fee

10

Arcs

Tell Me / Show Me
Arcs, Supertypes, and
Subtypes (continued)
Supertypes and subtypes
can sometimes be drawn
as arcs.
The supertype PARTNER
in the DJ model is
represented as an arc in
this diagram.

Copyright 2010, Oracle. All rights reserved.

11

Arcs

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Arc
Constraint
Exclusive OR relationship
Mutually exclusive relationship

Copyright 2010, Oracle. All rights reserved.

12

Arcs

Summary
Objectives Summarized
In this lesson, you have learned how to:
Define the term "constraint" as it applies to data
modeling
Identify an exclusive OR relationship in a business
scenario
Diagram an arc constraint to represent an exclusive OR
relationship
Distinguish between the use of an arc and a subtype in
the data model

Copyright 2010, Oracle. All rights reserved.

13

Arcs

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

14

Hierarchies and Recursive Relationships

Copyright 2011, Oracle. All rights reserved.

Hierarchies and Recursive Relationships

What Will I Learn?


Objectives
In this lesson, you will learn to:
Define and give an example of a hierarchical
relationship
Identify the UIDs in a hierarchical model
Define and give an example of a recursive relationship
Represent a recursive relationship in an ERD given a
scenario
Construct a model using both recursion and
hierarchies to express the same conceptual meaning

Copyright 2010, Oracle. All rights reserved.

Hierarchies and Recursive Relationships

Why Learn It?


Purpose
Often, roles are organized by hierarchy -- at work (manager,
crew chief, front-counter clerk, food preparers), or in school
(headmaster or principal, assistant headmaster or assistant
principal, teachers, staff). Hierarchical data is very common.
Understanding it will help you model:

Business organizational charts


Building structures
Family trees

and many other hierarchies found in the real world.

Copyright 2010, Oracle. All rights reserved.

Hierarchies and Recursive Relationships

Tell Me / Show Me

President

Relationships in an Organizational Chart


An organizational chart can be represented
by this data model. What are the UIDs for
each entity?

the
manager
of
reporting to

Director
the
manager
of

President

reporting to

Director

Manager

Entry Level Employee

Manager
the
manager
of
reporting to

Entry-Level
Employees

Copyright 2010, Oracle. All rights reserved.

Hierarchies and Recursive Relationships

Tell Me / Show Me
Another Relationship
Example
What are the UIDs for each
entity in this ERD? (Notice the
barred relationships.)

BUILDING
#* id
* name
* address
located
the location of
FLOOR
#* number
located
the location of
SUITE
#* number
o tenant
located
the location of
ROOM
# id

Copyright 2010, Oracle. All rights reserved.

Hierarchies and Recursive Relationships

Tell Me / Show Me
Hierarchy Versus
Recursive Relationship
Both of these models
represent all employees.
The one on the left is a
hierarchical structure. The
one on the right uses a
recursive relationship.
Which one do you think is
better?

PRESIDENT
# badge number
* name
o salary
* car plan

DIRECTOR
# badge number
* name
o salary
* bonus plan

MANAGER
# badge number
* name
o salary
* budget

EMPLOYEE
# badge number
* first name
* job
o salary
o budget
o bonus plan
o car plan

managed
by

the manager
of

ENTRY-LEVEL EMPLOYEE
# badge number
* name
o salary

Copyright 2010, Oracle. All rights reserved.

Hierarchies and Recursive Relationships

Tell Me / Show Me
DJs on Demand
Business Scenario
In the DJ model, the
project manager has
overall responsibility for
an event and manages
the other employees
(event planner, DJ)
working on the event.
We chose to represent
the hierarchy with a
recursive relationship.

PARTNER
# id
* first name
* last name
EVENT PLANNER
* expertise

OTHER

DJ
* specialty

supervise

MANAGER
o authorized expense report

supervised by

Copyright 2010, Oracle. All rights reserved.

Hierarchies and Recursive Relationships

Tell Me / Show Me
Automobile
Manufacturing
Business Scenario
For an automobile
manufacturing
organization, consider all
elementary parts,
subassemblies,
assemblies, and
products as instances of
an entity called
COMPONENT. The
model can be created as
a simple recursive
relationship.

A part of

COMPONENT
# identifier

Made up of

Model Bill of Materials data as a manyto-many recursive relationship:


Each COMPONENT may be a
part of one or more
COMPONENTS.
Each COMPONENT may be
made up of one or more
COMPONENTS.

Copyright 2010, Oracle. All rights reserved.

Hierarchies and Recursive Relationships

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Hierarchal relationship
Recursive relationship

Copyright 2010, Oracle. All rights reserved.

Hierarchies and Recursive Relationships

Summary
Objectives Summarized
In this lesson, you have learned how to:
Define and give an example of a hierarchical relationship
Identify the UIDs in a hierarchical model
Define and give an example of a recursive relationship
Represent a recursive relationship in an ERD given a
scenario
Construct a model using both recursion and hierarchies to
express the same conceptual meaning

Copyright 2010, Oracle. All rights reserved.

10

Hierarchies and Recursive Relationships

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

11

Modeling Historical Data

Copyright 2011, Oracle. All rights reserved.

Modeling Historical Data

What Will I Learn?


Objectives
In this lesson, you will learn to:

Identify the need to track data that changes over time

Construct ERD models that incorporate elements of data over time

Identify the UID of an entity that stores historical data; explain and
justify the choice of UID

Construct a conceptual model based on a given business scenario

Apply the rules of entity-relationship diagramming to create an ERD


that reflects the business rules

Present and interpret the data model to an audience

Compose written documentation to accompany the oral presentation


and an ERD

Copyright 2010, Oracle. All rights reserved.

Modeling Historical Data

Why Learn It?


Purpose
How tall were you at age 5? How tall were you at age 10? How tall are you
right now? If your parents wrote this down when you were young, they
were keeping track of historical data. Most businesses need to track some
historical data. This helps them find trends and patterns that can be the
basis for business innovations or process improvements.
For example, rental history of a movie is useful to a video store. It tells
managers which movies are popular and which should be moved to the
back shelf.
Can you think of an application for a pharmaceutical company, a
commercial dairy or bakery, or a seafood-processing plant? What historical
data would each want to keep and why?

Copyright 2010, Oracle. All rights reserved.

Modeling Historical Data

Tell Me / Show Me
Model Data Over Time
When is it necessary to model data over time?
Ask your client:
Is an audit trail required?
Can attribute values change over time?
Can relationships change over time?
Do you need to produce reports on older data?
Do you need to keep previous versions of the
data? If so, for how long?

Copyright 2010, Oracle. All rights reserved.

Modeling Historical Data

Tell Me / Show Me
Data Over Time Example
An organization needs to keep data about
employees salaries. All employees are
paid weekly.

EMPLOYEE
# id
* first name
* last name
* weekly salary amount
* salary start date

Initially, the following EMPLOYEE entity


was modeled.
Additional requirements now specify that
the organization needs to keep a historical
record of how and when employees
salaries have changed during their
employment.

Copyright 2010, Oracle. All rights reserved.

Modeling Historical Data

Tell Me / Show Me
Model Salary Changes
To model salary changes over time, add a SALARY
HISTORY entity.
SALARY HISTORY
# salary start date
o salary end date
* weekly salary amount

EMPLOYEE
# id
* first name
* last name

for

having

The UID of the SALARY HISTORY entity is the related EMPLOYEE id


and the salary start date.

Copyright 2010, Oracle. All rights reserved.

Modeling Historical Data

Tell Me / Show Me
Model Rental Over Time
A jewelry store rents pieces
(necklaces, bracelets and so on)
to movie stars for special
occasions, such as award
ceremonies or movie premieres.
They would like to track the
rental history of a jewelry piece.
The following ER model will only
track the current renter of a piece
of jewelry.

JEWELRY PIECE
rented by
# code
* description
* rental rate
renting
* insured value

MOVIE STAR
# id
* first name
* last name

How would you revise the


relationship to track history?

Copyright 2010, Oracle. All rights reserved.

Modeling Historical Data

Tell Me / Show Me
Resolve M:M
The relationship between
JEWELRY PIECE and
MOVIE STAR should be
revised to a M:M, which is
then resolved with an
intersection entity
RENTAL HISTORY.
What is the UID of
RENTAL HISTORY?

JEWELRY PIECE
rented by
# code
* description
* rental rate
renting
* insured value

MOVIE STAR
# id
* first name
* last name

The M:M relationship is resolved with an


intersection entity.
RENTAL HISTORY
* date
* date returned

for
on

MOVIE STAR
# id
* first name
* last name

for
on
JEWELRY PIECE
# code
* description
* rental rate
* insured value

Copyright 2010, Oracle. All rights reserved.

Modeling Historical Data

Tell Me / Show Me
Barred Relationship
The UID of RENTAL
HISTORY is date rented and
the UID of JEWELRY PIECE
(shown by the barred
relationship).

RENTAL HISTORY
# date
* date returned

for

on

MOVIE STAR
# id
* first name
* last name

for
on
JEWELRY PIECE
# code
* description
* rental rate
* insured value

Copyright 2010, Oracle. All rights reserved.

Modeling Historical Data

Tell Me/ Show Me


Terminology
Historical data
Audit trail

Copyright 2010, Oracle. All rights reserved.

10

Modeling Historical Data

Summary
Objectives Summarized
In this lesson, you have learned how to:

Identify the need to track data that changes over time

Construct ERD models that incorporate elements of data over time

Identify the UID of an entity that stores historical data; explain and
justify the choice of UID

Construct a conceptual model based on a given business scenario

Apply the rules of entity-relationship diagramming to create an ERD


that reflects the business rules

Present and interpret the data model to an audience

Compose written documentation to accompany the oral presentation


and ERD

Copyright 2010, Oracle. All rights reserved.

11

Modeling Historical Data

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

12

Presentation of the ERD to the Client

Copyright 2011, Oracle. All rights reserved.

Presentation of the ERD to the Client

What Will I Learn?


Objectives
In this lesson, you will learn to:
Share and translate the ER model with the client in an
engaging way
Use non-technical terms when describing the ER model
to the client
Document design revisions requested by the client

Copyright 2010, Oracle. All rights reserved.

Presentation of the ERD to the Client

Why Learn It?


Purpose
Continue to apply what youve learned and simulate a realworld situation.

Most clients will not be familiar with data-modeling


techniques and terminology. Using their own business terms
and examples will help your client understand your
presentation and model.

Copyright 2010, Oracle. All rights reserved.

Presentation of the ERD to the Client

Tell Me / Show Me
Tell Your Story
Your presentation should be organized and well prepared. It
is a good idea to assign roles and responsibilities to
different group members for each part of the presentation.
This presentation provides you an opportunity, as a
consultant, to check your assumptions of the business
requirements with the Director. Tell the story that the client
told you during your initial meeting while showing and
explaining the ERD.

Copyright 2010, Oracle. All rights reserved.

Presentation of the ERD to the Client

Tell Me / Show Me
Use a Simple Vocabulary
Consultants should not use technical terms with the client such
as unique identifier, attribute, or entity. Clients do not know
what these things are. You can, and should, show the client
how to read relationships on the diagram. Once the client
understands how to read the diagram, they should be able to
help verify if the relationship is correct.
This is also a time for you to make sure that you are gathering
all the data the client requires for each of the entities. For
example, "Is there any other information that you would like to
know about your adopters besides name and address?"

Copyright 2010, Oracle. All rights reserved.

Presentation of the ERD to the Client

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Consultant
Client

Copyright 2010, Oracle. All rights reserved.

Presentation of the ERD to the Client

Summary
Objectives Summarized
In this lesson, you have learned to:
Share and translate the ER model with the client in an
engaging way
Use nontechnical terms when describing the ER model to the
client
Document design revisions requested by the client

Copyright 2010, Oracle. All rights reserved.

Presentation of the ERD to the Client

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Time

Copyright 2011, Oracle. All rights reserved.

Modeling Change: Time

What Will I Learn?


Objectives
In this lesson, you will learn to:
Distinguish between using date as an attribute and DAY
as an entity in a data model, depending on business
requirements
Solve the problem of keeping characteristics of a date by
constructing a model that uses DAY as an entity
Identify at least three time-related constraints that can
result from a time-sensitive model
Define and give an example of conditional nontransferability in a time-constrained model

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Time

Why Learn It?


Purpose
Time plays a role in many business models.
For example: A book may be checked out from
the library several times, by different people, or
by the same person. The model may need to
track a history of borrowing for a book. Think
about a florist-supply company or a city police
department. How could time play a role in their
information needs?

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Time

Why Learn It?


Purpose (continued)
Historical data is often used by businesses to find trends
that can point the way to more efficient ways of doing
business. Modeling time in a business allows such data to
be captured.
Reports provide information that can be derived from the
data. A well-designed report can provide valuable
information that the business can use to improve its
operations.

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Time

Tell Me / Show Me
Entity DAY vs. Attribute Date
Consider the entity PURCHASE. You
would include an attribute date if you
wanted to know when the item was
purchased. However, if we wanted to
identify trends -- such as when do
people buy coats vs. bathing suits vs.
sneakers? We may want to know the
temperature during that time.
What is wrong with the revised entity
shown here?

Copyright 2010, Oracle. All rights reserved.

PURCHASE
# id
* date
* quantity
* unit price

PURCHASE
# id
* date
* quantity
* unit price
* high temperature
* low temperature

Modeling Change: Time

Tell Me / Show Me
Entity DAY vs. Attribute Date
(continued)
Remember Third Normal Form: a
non-UID attribute cannot have
attributes of its own.
Because high and low
temperature are attributes of the
date, we need a separate entity
DAY.

PURCHASE
# id
* quantity
* unit price

DAY
# date
the time for * high temperature
* low temperature

made on

Can you think of a useful report


that the business could produce
from this data?
Copyright 2010, Oracle. All rights reserved.

Modeling Change: Time

Tell Me / Show Me
Entity DAY vs. Attribute Date (continued)

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Time

Tell Me / Show Me
Time-related Constraints
Be aware of constraints that can result from
the need to track dates and times. Here is an
example:

sdm_s10_l01_a01

Consider a school fair that features several


booths. The manager signs up volunteers to
work different shifts at different booths. A
booth is staffed by only one volunteer at a
time. Some volunteers can work for several
hours; others can work fewer hours
depending on their free time. The schedule
has to be determined in advance, so that the
manager knows which times are not covered
by any volunteers.
Copyright 2010, Oracle. All rights reserved.

Modeling Change: Time

Tell Me / Show Me
Time-related Constraints
(continued)

Here is a selection of time-related


constraints that need to be
considered for this model:
The obvious one: shift end time
must be later than shift start
time.
Shift times may not overlap. The
start time for a shift for a
volunteer may not be between
any start time and end time of
another volunteer on the same
booth. The same is true for the
end time.

SHIFT ASSIGNMENT SCHEDULE


# date
# start time
* end time

for

for

worked by
BOOTH
# id
* name

Copyright 2010, Oracle. All rights reserved.

work on
VOLUNTEER
# number
* name

Modeling Change: Time

Tell Me / Show Me
Conditional Non-transferability
The start time for a shift may be
updated to a later time, unless the
shift has already begun.

SHIFT ASSIGNMENT SCHEDULE


# date
# start time
* end time

for

for

The start time for a shift may be


updated to an earlier time, unless
the shift has already begun.
You probably would not allow a
shift to be reassigned to another
volunteer or another booth, unless
the shift had not yet started. This
is an example of conditional nontransferability.

worked by
BOOTH
# id
* name

Copyright 2010, Oracle. All rights reserved.

work on
VOLUNTEER
# number
* name

10

Modeling Change: Time

Tell Me / Show Me
Conditional Non-transferability
(continued)
Non-transferability: a SHIFT
ASSIGNMENT cannot be changed
to another BOOTH (or to another
VOLUNTEER). Nontransferable
relationships are represented by a
diamond in the ERD.
Conditional non-transferability: a
SHIFT ASSIGNMENT can
sometimes be changed in this
case, if the shift has not yet started.
These relationships cannot be
represented in the diagram, but
must still be documented.

SHIFT ASSIGNMENT SCHEDULE


# date
# start time
* end time

for

for

worked by
BOOTH
# id
* name

Copyright 2010, Oracle. All rights reserved.

work on

VOLUNTEER
# number
* name

11

Modeling Change: Time

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Time-related constraint
Non-transferability
Conditional non-transferability

Copyright 2010, Oracle. All rights reserved.

12

Modeling Change: Time

Summary
Objectives Summarized
In this lesson, you have learned to:
Distinguish between using date as an attribute and DAY
as an entity in a data model, depending on business
requirements
Solve the problem of keeping characteristics of a date
by constructing a model that uses DAY as an entity
Identify at least three time-related constraints that can
result from a time-sensitive model
Define and give an example of conditional nontransferability in a time-constrained model

Copyright 2010, Oracle. All rights reserved.

13

Modeling Change: Time

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

14

Modeling Change: Price

Copyright 2011, Oracle. All rights reserved.

Modeling Change: Price

What Will I Learn?


Objectives
In this lesson, you will learn to:
Solve the business requirement of tracking changes in
price or values by constructing a model that uses a
historical entity
Describe the meaning of journaling/logging
Identify the business need for journaling/logging and
construct a model that addresses this requirement

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Price

Why Learn It?


Purpose
Historical prices are important when looking for trends,
determining appreciation or depreciation value of items, or
getting a refund for an item purchased in the past at a
previous price.
Many businesses track history of change, who changed it,
when it was changed, and so on.
Example: if a students grade is changed, it is useful to
record when it was changed, the old grade, the new grade,
and who changed it.

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Price

Tell Me / Show Me
The Importance of Price Changes
Changes in price are often an important
consideration when modeling business
requirements. Some examples would
be:
The stock market: Prices are
changing by the second and you are
watching the reader board, wondering
when to buy and when to sell. What
factors would you consider?
sdm_s10_l02_a01

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Price

Tell Me / Show Me
The Importance of Price Changes (continued)
The fuel industry: Why would you want to track the price
changes in fuel if you are thinking of buying a car or during
the winter when you heat your home?
Construction businesses: Why are price
changes important to a contractor of a five-year bridgeconstruction project?

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Price

Tell Me / Show Me
The Good Old Days
The prices of products change over
time. Some go up.

sdm_s10_l02_a02

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Price

Tell Me / Show Me
Can You Believe What I Paid for It?
The prices of products change over
time. Some go down.

sdm_s10_l02_a03

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Price

Tell Me / Show Me
Whats the Price Today?
The prices of products change over
time. Some go up and down.

sdm_s10_l02_a04

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Price

Tell Me / Show Me
Model Historical Price
It is often useful to have
information on past prices.

PRODUCT
# id
* name

with

The model shown here tracks


the historical price of a
product.
of

PRICE
# start date
o end date
* price

Copyright 2010, Oracle. All rights reserved.

Modeling Change: Price

Tell Me / Show Me
Historical Price Changes
Consider what happens when you
return an item to a store. You
purchased the item at a certain price,
but it has gone on sale since then.

sdm_s10_l02_a05

Copyright 2010, Oracle. All rights reserved.

10

Modeling Change: Price

Tell Me / Show Me
Tracking Price Changes
Businesses often need to
keep a record of price
changes. In this model, we
assume that each
PURCHASE is of only one
product.
The price that was paid can
be found by matching the
purchase date between the
start date and the end date
of PRICE.

PURCHASE
# id
* purchase date
* quantity purchased

PRODUCT
# id
* name

with
between

of

PRICE
# start date
o end date
* price

Copyright 2010, Oracle. All rights reserved.

11

Modeling Change: Price

Tell Me / Show Me
Other Data Changing Over Time
Weve seen that price changes over
time. There are other types of
information that can also change, for
different business reasons.

sdm_s10_l02_a06

Copyright 2010, Oracle. All rights reserved.

12

Modeling Change: Price

Tell Me / Show Me
Journaling
Whenever a system allows a
user to modify or remove
particular information, the
question should be asked if
the old values need to be kept
on record. This is called
"logging" or "journaling." This
is often an issue when the
information is financial or of a
sensitive nature, such as a
student grade change.

made by
PAYMENT
# id
* date paid
* amount

for

with

of
AMOUNT MODIFICATION
* old amount
* modified by
# date modified

Copyright 2010, Oracle. All rights reserved.

13

Modeling Change: Price

Tell Me / Show Me
Journal Content
A journal usually consists of both
the modified value and the
information about who did the
modification and when it was
done. This extra information can,
of course, be expanded if you
wish.

EMPLOYEE
# id
* first name
* last name
* salary amount

with

for
SALARY CHANGE
# date modified
* old salary amount
* modified by

Copyright 2010, Oracle. All rights reserved.

14

Modeling Change: Price

Tell Me / Show Me
Terminology
Key terms used in this lesson include:
Appreciation
Depreciation
Journaling and / or logging

Copyright 2010, Oracle. All rights reserved.

15

Modeling Change: Price

Summary
Objectives Summarized
In this lesson, you have learned to:

Solve the business requirement of tracking changes in


price or values by constructing a model that uses a
historical entity
Describe the meaning of journaling/logging
Identify the business need for journaling/logging and
construct a model that addresses this requirement

Copyright 2010, Oracle. All rights reserved.

16

Modeling Change: Price

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

17

Adding the Time Element to an ERD

Copyright 2011, Oracle. All rights reserved.

Adding the Time Element to an ERD

What Will I Learn?


Objectives
In this lesson, you will learn to:
Apply the rule of using DATE as an entity successfully
Modify an ERD to accommodate new design requirements
Identify and design possible reports that can be produced
from the data; explain how the information from these
reports could be useful to the business

Copyright 2010, Oracle. All rights reserved.

Adding the Time Element to an ERD

Why Learn It?


Purpose
Historical data is often used by businesses to find trends
that can point the way to more efficient ways of doing
business. Modeling time in a business allows such data to
be captured.
Reports provide information that can be derived from the
data. A well-designed report can provide valuable
information that the business can use to improve its
operations.

Copyright 2010, Oracle. All rights reserved.

Adding the Time Element to an ERD

Tell Me / Show Me
Business Scenario
View how the director of the
animal shelter provides new
business requirements.

sdm_s10_l03_a01

Copyright 2010, Oracle. All rights reserved.

Adding the Time Element to an ERD

Summary
Objectives Summarized
In this lesson you have learned to:
Apply the rule of using DATE as an entity successfully
Modify an ERD to accommodate new design requirements
Identify and design possible reports that can be produced from
the data; explain how the information from these reports could
be useful to the business

Copyright 2010, Oracle. All rights reserved.

Adding the Time Element to an ERD

Summary
Practice Guide
The link for the lesson practice guide can be found in the
course resources in Section 0.

Copyright 2010, Oracle. All rights reserved.

Potrebbero piacerti anche