Chapter 6

advertisement
6
Chapter 6
Database Design 2:
Design Methodology
Concepts of Database Management, 4th Edition, Pratt & Adamski
1
Objectives

Discuss the general process and goals of
database design

Define user views and explain their
function

Define database design language and use
it to document database designs

Create an entity-relationship diagram to
visually represent a database design
6
 Present
a methodology for database
design at the information level and view
examples illustrating this methodology
Concepts of Database Management, 4th Edition, Pratt & Adamski
2
6
Objectives

Explain the physical-level design process

Examine some alternative approaches to
entity-relationship diagrams

Discuss top-down and bottom-up
approaches to database design and
examine the advantages and
disadvantages of both methods

Use a survey form to obtain information
from users prior to beginning the
database design process
Concepts of Database Management, 4th Edition, Pratt & Adamski
3
Objectives
6
 Review
existing documents to obtain
information from users prior to beginning
the database design process
 Discuss
special issues related to
implementing one-to-one relationships
and many-to-many relationships involving
more than two entities
 Discuss
entity subtypes and their
relationships to nulls
 Learn
how to avoid potential problems
when merging third normal form relations
Concepts of Database Management, 4th Edition, Pratt & Adamski
4
6
Database Design
 User

Views
Requirements necessary to support a particular
user’s operations
 Information-level




Design Methodology
Represent user view as collection of tables
Normalize these tables
Identify all keys
Merge the result into design
Concepts of Database Management, 4th Edition, Pratt & Adamski
5
Represent User View as
Collection of Tables
Step 1:
Step 2:
Step 3:
Step 4:
6
Determine entities involved and
create separate table for each
type
Determine primary key for each
table
Determine properties for each
entities
Determine relationships among
entities
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
6
Normalize the Tables
 Represent

Primary, alternate, secondary, foreign
 Database

all keys
Design Language (DBDL)
Mechanism for representing tables and keys
Concepts of Database Management, 4th Edition, Pratt & Adamski
7
6
DBDL Notation
 Table
name followed by columns in
parentheses

Primary key column(s) underlined
 AK
identifies alternate keys
 SK identifies secondary keys
 FK identifies foreign keys
Concepts of Database Management, 4th Edition, Pratt & Adamski
8
Entity-Relationship Diagrams
Figure 6.2
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
9
Merge the Result into the Design
Figure 6.3
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
10
6
User View Examples
View #1: Sales Rep View
Rep (RepNum, LastName, FirstName, Street,
City, State, Zip, Commission, Rate)
Concepts of Database Management, 4th Edition, Pratt & Adamski
11
User View Examples (con’t.)
Figure 6.5
6
View #2: Customer View
Concepts of Database Management, 4th Edition, Pratt & Adamski
12
User View Examples (con’t.)
Figure 6.6
6
View #3: Part View
Concepts of Database Management, 4th Edition, Pratt & Adamski
13
User View Examples (con’t.)
Figure 6.8
6
View #4: Order View
Concepts of Database Management, 4th Edition, Pratt & Adamski
14
6
Second Set User View Examples
View #1: Publisher View
Publisher (PublisherCode, PublisherName, City)
SK PublisherName
Concepts of Database Management, 4th Edition, Pratt & Adamski
15
Second Set User View Examples
(con’t.)
6
View #2: Branch View
Publisher (PublisherCode, PublisherName, City)
SK PublisherName
Branch (BranchNum, BranchName,
BranchLocation, NumEmployees)
SK BranchName
Concepts of Database Management, 4th Edition, Pratt & Adamski
16
Second Set User
View Examples (con’t.)
Figure 6.11
6
View #3: Book View
Concepts of Database Management, 4th Edition, Pratt & Adamski
17
Second Set User
View Examples (con’t.)
Figure 6.12
6
View #4: Author View
Concepts of Database Management, 4th Edition, Pratt & Adamski
18
Second Set User
View Examples (con’t.)
Figure 6.13
6
View #5 and View #6: Inventory View
Concepts of Database Management, 4th Edition, Pratt & Adamski
19
6
Physical-Level Design
 Undertaken
after information-level design
completion
 Most DBMSs support primary, candidate,
secondary, and foreign keys
 DB programmers must include logic to
ensure the uniqueness of primary keys and
enforce other conditions
Concepts of Database Management, 4th Edition, Pratt & Adamski
20
ERD Relationship Alternative
Figure 6.14
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
21
Symbols for Columns
Figure 6.15
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
22
Composite Entity
Figure 6.16
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
23
Crow’s Foot Symbol
Figure 6.17
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
24
Representing Cardinality
Figure 6.18
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
25
6
Top-Down vs. Bottom-Up
 Bottom-up


Design starts at low level
Specific user requirements drive design process
 Top-down


Begins with general database that models overall
enterprise
Refines the model until design is achieved
Concepts of Database Management, 4th Edition, Pratt & Adamski
26
6
Survey Form
 Used
to collect information from users
 Must contain particular elements





Entity information
Attribute information
Relationships
Functional dependencies
Processing information
Concepts of Database Management, 4th Edition, Pratt & Adamski
27
6
Existing Documents
 Aid
in collecting user requirements
 Collect information similar to that collected
with survey forms





Entity information
Attribute information
Relationships
Functional dependencies
Processing information
Concepts of Database Management, 4th Edition, Pratt & Adamski
28
1:1 Relationship Considerations
Figure 6.25
6
Include primary key of
each table as foreign
key in the other
Concepts of Database Management, 4th Edition, Pratt & Adamski
29
1:1 Relationship Considerations
Figure 6.26
6
Implementation when
information does not
match.
Concepts of Database Management, 4th Edition, Pratt & Adamski
30
1:1 Relationship Considerations
Figure 6.27
6
Implemented in a single
table.
Concepts of Database Management, 4th Edition, Pratt & Adamski
31
1:1 Relationship Considerations
Figure 6.28
6
1:1 relationship implemented by
including primary key of one table
as foreign key (and alternative key)
in the other.
Concepts of Database Management, 4th Edition, Pratt & Adamski
32
M:M Relationship Considerations
Figure 6.29
6
Sample Sales Data
Concepts of Database Management, 4th Edition, Pratt & Adamski
33
M:M Relationship Considerations
Figure 6.30
6
Result obtained by splitting
Sales table into three tables
Concepts of Database Management, 4th Edition, Pratt & Adamski
34
M:M Relationship Considerations
Figure 6.31
6
Result obtained by joining three tables--2 rows
are in error. Must be converted to 4NF.
Concepts of Database Management, 4th Edition, Pratt & Adamski
35
Table Split to Avoid Nulls
Figure 6.32
6
Nulls are absence
of values
Concepts of Database Management, 4th Edition, Pratt & Adamski
36
Entity Subtypes
Figure 6.34
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
37
Student Table Split to
Avoid Nulls
Figure 6.36
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
38
Two Entity Subtypes—
Incomplete Categories
Figure 6.37
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
39
Two Entity Subtypes—
Complete Categories
Figure 6.38
Concepts of Database Management, 4th Edition, Pratt & Adamski
6
40
Download