Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Objectives
Define database terms
Identify the purpose of a database management
system (DBMS)
Explain database design using entity-relationship
models and normalization
Explain the purpose of a Structured Query
Language (SQL)
Understand how this textbooks topics are
sequenced and how the two sample databases are
used
Dr. Chen, Business Database Systems
What is Information ?
DATA
INFORMATION
DataBase
Management
Systems
Old
State
Activities
Picture
Or
Model
Events
New
State
Transactions
(Add, modify, delete, )
D.B.
TM 0-6
Questions
Is MS/Access or Oracle (SQL/Server or
IBM DB2) a data base?
Why dont we just create a huge data file
containing all fields (columns)?
Have you ever created a database (with many
applications) with only one huge data file
containing all fields (columns)?
Problems:
Data dependence: data structures are tightly coupled with
applications. In other words, we prefer data independence.
Data redundancy: same data are repeatedly saved for
different applications.
Other problems
Dr. Chen, Business Database Systems
Duplicate
Data
11
Application
#2
Application
#3
DBMS
Database
containing
centralized
shared data
Data Files
Product
Supplier
Name, item#,
description...
Sales
order processing
system
Name, item#,
description...
Sales rep
Product
D a tab a s e
P u rch a sing
Sys te m
D a ta b a s e
M an a g e m e n t
Sys te m s
P rodu ct
S ales rep
S a le s
o rd er pro ce s s in g
sys te m
S up plie r
Database Terminology
Database an organized collection of
logically related data files
Database management system
(DBMS) software used to create
and interact with the database
15
Database Components
Character
Basic unit of data
Can be a letter, number, or special symbol
Field
A group of related characters
Represents an attribute or characteristic of an entity
Corresponds to a column in the physical database
Record
A collection of fields for one specific entity
Corresponds to a row in the physical database
File
16
Relational Databases
Data is organized in tables
Columns (fields) represent different data categories
Rows (records) contain actual data values
17
Database Example
18
Components Example
primary keys
candidate keys
surrogate keys
foreign keys
composite keys
20
21
Surrogate Keys
Surrogate key: created to be the records primary key
identifier when no suitable primary key exists
Surrogate key has no real relationship to the record to
which it is assigned, other than to identify the record
uniquely
Developers configure the database to generate
surrogate key values automatically
In an Oracle database, you can automatically generate
surrogate key values using a sequence
Surrogate keys are always numerical fields, because
the database generates surrogate key values
automatically by incrementing the previous value by
one
Dr. Chen, Business Database Systems
22
Foreign Keys
Foreign key: a field in a table that is a primary key in
another table
Foreign key creates a relationship between the two tables
Foreign key value must exist in the table where it is a
primary key
23
Composite Key
Composite key: a unique key that you create by
combining two or more fields
Usually comprised of fields that are primary keys
in other tables
Composite
Key
ORDER_ID
PRODUCT_ID
ORDER_QUANTITY
100
100
200
200
24
25
Client/Server Database
Management Systems
Client/server database
Takes advantage of distributed processing and networked
computers by distributing processing across multiple
computers
DBMS server process runs on one workstation, and the
database applications run on separate client workstations
across the network
Preferred for database applications that retrieve and
manipulate small amounts of data from databases
containing large numbers of records because they
minimize network traffic and improve response times
26
DATABASE TRENDS
Linking Internal Databases to the Web
N
Dr. Chen, Business Database Systems
28
1. Request for
Network
8. Data-based
Web page
Web Browser
3. Data query
6. Retrieved data
7. Data-based
Web page
4. Data
query
Web server
5. Retrieved
data
Legend
Communications
Between Web browser
And Web server
Database Server
Dr. Chen, Business Database Systems
Communications
Between Web server
And database server
29
30
31
Description
SQL
SQL*Plus
PL/SQL
Terminal
Buffer
SQL and
PL/SQL
Scripts
Dr. Chen, Business Database Systems
SQL*Plus
Server
Design Principles
To avoid creating tables that contain redundant
data, group related items that describe a single
entity together in a common table
Do not create tables that duplicate values many
times in different rows
When creating a database and inserting data
values, you must specify the data type for each
column
Recall that primary key fields should use a number
data type to avoid typographical, punctuation, and
case variation errors
Dr. Chen, Business Database Systems
33
Database Design
Systems Development Life Cycle (SDLC)
Entity-relationship model (E-R model)
Normalization
34
Systems Investigation
(Definition) Product:
Feasibility Study
Systems Analysis
Product:
Functional Requirements
Systems Design
Product:
System Specifications
Implement
the Information
System
Solution
Systems Implementation
Product:
Operational System
Systems Maintenance
Product:
Improved System
Dr. Chen, Business Database Systems
36
Data Models
A data model is a collection of concepts for
describing data.
Three database models
Hierarchical
Network
Relational
CUSTOMER
Dr. Chen, Business Database Systems
ORDER
37
Entity-Relationship Model
(E-R Model)
Used to depict the relationship that exists among
entities
The following relationships can be included in
an E-R model:
One-to-one
One-to-many
Many-to-many
Please note that the name of entity should be singular even it contains multiple
instances
39
One-to-One Relationship
Each occurrence of data in one entity is
represented by only one occurrence of data
in the other entity
Example: Each order has just one invoice
and each invoice is assigned to just one
order
ORDER
INVOICE
41
One-to-Many Relationship
Each occurrence of data in one entity can be
represented by many occurrences of the
data in the other entity
Example: A class has only one instructor,
but each instructor can teach many classes
Class
Instructor
42
Many-to-Many Relationship
Data can have multiple occurrences in both
entities
Example: A student can take many classes,
and each class is composed of many
students
Can not be included in the physical database
Class
Student
43
44
45
Cost
Retail
Category
Publisher
Contact
Author
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
T.Peterson
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Austin
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Adams
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
W.White
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
L.White
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
M.Kane
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
S. Little
ISBN
Title
8843172113
Database Normalization
Purposes
design a reliable and stable data bases
increase data integrity (reduce or control data
redundancy)
Processes
determines required tables and columns for
each table
multistep process
Dr. Chen, Business Database Systems
47
Business Problem
???
IMPLEMENTATION
Dr. Chen, Business Database Systems
Business Problem
IMPLEMENTATION
Well-Structured Relations
A relation that contains minimal data redundancy
and allows users to insert, delete, and update rows
without causing data inconsistencies
Goal is to avoid (minimize) anomalies
Insertion Anomaly adding new rows forces user to
create duplicate data
Deletion Anomaly deleting rows may cause a loss of
data that would be needed for other future rows
Modification Anomaly changing data in a row forces
changes to other rows because of duplication
50
51
Unnormalized Data
Contains repeating groups in the Author column
in the BOOKS table
Fifth normal
form (5NF)
Dr. Chen, Business Database Systems
Remove Repeating
Group Attributes
Remove
Remove
Remove remaining
anomalies resulting from
multiple candidate keys
Remove Multivalued
Dependencies
Remove Remaining
Anomalies
55
1NF: ISBN and Author fields together create a composite primary key
Q: What fields are dependent on ISBN alone ?
Publication
Date
Cost
Retail
Category
Publisher
Contact
Author
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
T.Peterson
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Austin
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Adams
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
W.White
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
L.White
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
M.Kane
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
S. Little
ISBN
Title
8843172113
58
59
Second-Normal
ISBN
Author
Publication
Date
Cost
Retail
Category
Publisher
Contact
8843172113
T.Peterson
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
8843172113
J.Austin
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
American
Publishing
Davidson
8843172113
J.Adams
1915762492
W.White
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
1915762492
L.White
6522489652
M.Kane
6522489652
60
S. Little
ISBN
Title
8843172113
1NF: ISBN and Author fields together create a composite primary key
Q: What fields are dependent on ISBN alone ?
Publication
Date
Cost
Retail
Category
Publisher
Contact
Author
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
T.Peterson
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Austin
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Adams
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
W.White
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
L.White
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
M.Kane
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
S. Little
ISBN
Title
8843172113
Title
Publication
Date
Cost
Retail
Category
Publisher
Contact
Author
Cost
Retail
Category
Publisher
Contact
Author
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
T.Peterson
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Austin
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Adams
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
W.White
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
L.White
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
M.Kane
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
S. Little
ISBN
Title
8843172113
ISBN
Title
Publication
Date
Cost
Retail
Category
Publisher
Contact
Author
ISBN
Title
Publication
Date
Cost
Retail
Category
Publisher
Contact
Author
ISBN
Title
Publication
Cost Retail Category Publisher Contact
Date
ISBN Author
Cost
Retail
Category
Publisher
Contact
Author
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
T.Peterson
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Austin
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Adams
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
W.White
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
L.White
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
M.Kane
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
S. Little
ISBN
Title
8843172113
ISBN
Author
Publication
Date
Cost
Retail
Category
Publisher
Contact
8843172113
T.Peterson
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
8843172113
J.Austin
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
American
Publishing
Davidson
8843172113
J.Adams
1915762492
W.White
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
1915762492
L.White
6522489652
M.Kane
6522489652
S. Little
ISBN
Title
8843172113
Remove Repeating
Group Attributes
First normal
form (1NF)
Second normal
form(2NF)
Third normal
form (3NF)
Boyce-Codd normal
form (BC-NF)
Fourth normal
Form (4NF)
Fifth normal
form (5NF)
Dr. Chen, Business Database Systems
Remove Partial
Dependencies
Remove Transitive
Dependencies
Remove remaining
anomalies resulting from
multiple candidate keys
Remove Multivalued
Dependencies
Remove Remaining
Anomalies
68
ISBN
Title
Publication
Date
Cost
Retail
Category
Publisher
Contact
Author
Is it in the 3NF?
ISBN
Title
Publication
Cost Retail Category Publisher Contact
Date
ISBN Author
ISBN
Title
Publication
Cost Retail Category Publisher Contact
Date
ISBN Title
ISBN Publication Date
ISBN Category
ISBN Publisher
ISBN Contact
and
Category Contact
All this is OK
(2nd NF)
Dr. Chen, Business Database Systems
BUT
ISBN Category Contact
implies
ISBN Contact
Transitive dependency
(not in 3rd NF)
ISBN
ISBN
Title
Title
Publication
Cost Retail Category Publisher Contact
Date
Publication
Cost Retail Category Publisher
Date
Category
Contact
Cost
Retail
Category
Publisher
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
American
Publishing
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
ISBN
Title
8843172113
Category
Contact
Computer
Davidson
Accounting
Brown
Cost
Retail
Category
Publisher
Contact
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
American
Publishing
Davidson
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishin
g
Brown
Publication
Date
Cost
Retail
Category
Publisher
ISBN
Title
8843172113
ISBN
Title
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
American
Publishing
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Category
Contact
Computer
Davidson
Accounting
Brown
Title
Publication
Date
Cost
Retail
Category
Publisher
Contact
Author
ISBN Title
Publication
Cost Retail Category Publisher Contact
Date
ISBN Author
ISBN
Title
Publication
Cost Retail Category Publisher
Date
Category
Contact
Title
Publication
Date
Cost
Retail
Category
Publisher
Contact
Author
BOOKS
ISBN
Title
Publication
Cost Retail Category Publisher
Date
ISBN Author
CATEGORY_CONTACT
Category
Contact
Cost
Retail
Category
Publisher
Contact
Author
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
T.Peterson
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Austin
8843172113
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
Davidson
J.Adams
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
W.White
1915762492
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
Amercian
Publishing
Davidson
L.White
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
M.Kane
6522489652
Meaningful
Accounting
25-MAY-08
41.60
85.00
Accounting
Articulate
Publishing
Brown
S. Little
ISBN
Title
8843172113
Publication
Date
Cost
Retail
Category
Publisher
ISBN
Author
Database
Implementation
04-JUN-03
31.40
55.95
Computer
American
Publishing
8843172113
T.Peterson
8843172113
J.Austin
Handcranked
Computers
21-JUN-05
21.80
25.00
Computer
American
Publishing
8843172113
J.Adams
Meaningful
Accounting
25-MAY-08
1915762492
W.White
1915762492
L.White
6522489652
M.Kane
6522489652
S. Little
ISBN
Title
8843172113
1915762492
6522489652
41.60
85.00
Accounting
Articulate
Publishing
fk(foreign key)
Category Code
Category
Category
Contact
10
Computer
Computer
Davidson
50
Accounting
Accounting
Brown
Remove Repeating
Group Attributes
First normal
form (1NF)
Second normal
form(2NF)
Third normal
form (3NF)
Boyce-Codd normal
form (BC-NF)
Fourth normal
Form (4NF)
Fifth normal
form (5NF)
Dr. Chen, Business Database Systems
Remove Partial
Dependencies
Remove Transitive
Dependencies
Remove remaining
anomalies resulting from
multiple candidate keys
Remove Multivalued
Dependencies
Remove Remaining
Anomalies
78
Remove Repeating
Group Attributes
First normal
form (1NF)
Second normal
form(2NF)
Third normal
form (3NF)
Boyce-Codd normal
form (BC-NF)
Fourth normal
Form (4NF)
Fifth normal
form (5NF)
Dr. Chen, Business Database Systems
Remove Partial
Dependencies
Remove Transitive
Dependencies
Remove remaining
anomalies resulting from
multiple candidate keys
Remove Multivalued
Dependencies
Remove Remaining
Anomalies
80
Category_Contact
Category
Contact
Lookup Table
Common reference for descriptive data
tables referenced in a foreign key
fk(foreign key)
Category Code
Category
10
Computer
50
Accounting
82
83
84
Topic Sequence
The first half of the text will focus on
creating a database
The second half of the text will focus on
querying or retrieving data from a database
85
Summary
A DBMS is used to create and maintain a database
A database is composed of a group of interrelated tables
A file is a group of related records; a file is also called a table in the
physical database
A record is a group of related fields regarding one specific entity; a
record is also called a row
A common field is used to join data contained in different tables
A primary key is used to uniquely identify each record
A foreign key is a common field that exists between two tables but
is also a primary key in one of the tables
A lookup table is a common term for a table referenced in a foreign
key
A Structured Query Language (SQL) is a data sublanguage that
navigates the data stored within a databases tables
Dr. Chen, Business Database Systems
86
Summary (continued)
A record is considered unnormalized if it contains repeating
groups
A record is in first-normal form (1NF) if no repeating
groups exist and it has a primary key
Second-normal form (2NF) is achieved if the record is in
1NF and has no partial dependencies
After a record is in 2NF and all transitive dependencies have
been removed, then it is in third-normal form (3NF), which
is generally sufficient for most databases
87
SALES
Cust_ID
Name
Salesperson
Region
8023
Anderson
101
South
9167
Bancroft
102
West
7924
Hobbs
101
South
6837
Tucker
103
East
8596
Eckersley
102
West
7018
Arnold
104
North