Anda di halaman 1dari 30

SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

C H A P T E R

14 DATABASE
DESIGN

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Chapter Map

What is the
difference
between a
file and a
database?

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Conventional Files versus the Database

File – a collection of similar records.


– Files are unrelated to each other than for their use by a
common application program.
– Data storage is built around the applications that use
the files.

Database – a collection of interrelated files


– Records in one file (or table) are physically related to
records in another file (or table).
– Applications are built around the integrated database

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Files versus Database

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Pros and Cons of Conventional Files

Pros Cons
• Easy to design because of • Harder to share across
their single-application applications
focus • Harder to adapt to new
• Excellent performance due requirements
to optimized organization • May need to duplicate
for a single application attributes in several files.

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Pros and Cons of Databases

Pros Cons
• Data independence from • More complex than file
applications increases technology
adaptability and flexibility • Somewhat slower
• Superior scalability performance
• Ability to share data across • Investment in DBMS and
applications database experts
• Less redundancy (total non- • Need to adhere to design
redundancy is not always principles to realize benefits
achievable) • Increased vulnerability due
data consolidation

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Fields – Records – Files/Tables

Field

Record Field 1 Field 2 … Field m

File/Table

Record 1
Record 2

Record n

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Fields

Field – the smallest unit of meaningful data to be


stored in a database
– the physical implementation of a data attribute

Primary key – a field that uniquely identifies a record.

Secondary key – a field that identifies a single record or a


subset of related records.

Foreign key – a field that points to records in a different


file.

Descriptive field – any non-key field.

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Records

Record – a collection of fields arranged in a


predetermined format.
– Fixed-length record structures
– Variable-length record structures

Blocking factor – the number of logical records


included in a single read or write operation (from the
computer’s perspective).

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Files and Tables

File – the set of all occurrences of a given record structure.


Table – the relational database equivalent of a file.

• Types of conventional files and tables


– Master files – Records relatively permanent though values may
change
– Transaction files – Records describe business events
– Document files – Historical data for review without overhead of
regenerating document
– Archival files – Master and transaction records that have been
deleted
– Table lookup files – Relatively static data that can be shared to
maintain consistency
– Audit files – Special records of updates to other files

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Files and Tables

• File design methods require the analyst to specify


precisely how records in a database should be:
– Sequenced (File organization)
– Accessed (File access)

• Database methods usually predetermine and/or limit


such low-level activities:
– Trained database administrator control organization,
storage location, and access methods for performance
tuning.

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Data Architecture

Data architecture – a definition of how:


– Files and databases are to be developed and used to store data
– The file and/or database technology to be used
– The administrative structure set up to manage the data resource

Data is stored in some combination of:


– Conventional files
– Operational databases – databases that support day-to-day
operations and transactions for an information system
– Data warehouses – databases that store data extracted from
operational databases; to support data mining
– Personal databases
– Work group databases

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

A Modern Data Architecture

Conventional Operational
file database

Personal
database

DW

Work group
database
Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved
SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Database Architecture

Database architecture – the database technology used to support


data architecture
– Including the database engine, database utilities, CASE tools, and
database development tools.

Database management system (DBMS) – special software used


to create, access, control, and manage a database.
– The core of the DBMS is its database engine.
– A data definition language (DDL) is that part of the engine used to
physically define tables, fields, and structural relationships.
– A data manipulation language (DML) is that part of the engine
used to create, read, update, and delete records in the database,
and navigate between different records in the database.

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Typical DBMS Architecture

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Administrators

Data administrator or architect– a database specialist


responsible for data planning, definition, architecture,
and management.

Database administrator – a specialist responsible for


database technology, database design,construction,
security, backup and recovery, and performance tuning.
– A database administrator will administer one or more
databases

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Relational Databases

Relational database – a database that implements stored data in a


series of two-dimensional tables that are “related” to one
another via foreign keys.
– Database schema - a physical data model, a blueprint
representing the technical implementation of the database
– DDL – data definition language
– DML – data manipulation language
– SQL - Structured Query Language
• DDL and DML for a relational database
– Triggers – programs embedded within a database that are
automatically invoked by updates.
– Stored procedures – programs embedded within a database
that can be called from an application program.

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

From Logical Data Model …

ERD – Entity Relationship Diagram

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

… To Physical Data Model (Relational Schema)

Entities become
relational
tables

Primary keys
and foreign
keys implement
relations by
linking tables

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

User Interface for a Relational PC DBMS

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Goals of Database Design

• A database should provide for efficient storage,


update, and retrieval of data.

• A database should be reliable—the stored data should


have high integrity and promote user trust in that data.

• A database should be adaptable and scalable to new


and unforeseen requirements and applications.

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

What is a Good Data Model?

• A good data model is simple


– The data attributes that describe an entity should
describe only that entity

• A good data model is non-redundant


– Each data attribute exists in at most one entity (except
for foreign keys)

• A good data model should be flexible and adaptable to


future needs

These goals are achieved through database normalization.

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Database Normalization (also see Chapter 8)

• An logical entity (or physical table) is in first normal


form if there are no attributes (fields) that can have
more than one value for a single instance (record).

• An logical entity (or physical table) is in second


normal form if it is already in first normal form and if
the values of all nonprimary key attributes are
dependent on the full primary key.

• An logical entity (or physical table) is in third normal


form if it is already in second normal form and if the
values of all nonprimary key attributes are not
dependent on other nonprimary key attributes .
Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved
SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

A Method for Database Design

1. Review the logical data model.


2. Create a table for each entity.
3. Create fields for each attribute.
4. Create an index for each primary and secondary key.
5. Create an index for each subsetting criterion.
6. Designate foreign keys for relationships.
7. Define data types, sizes, null settings, domains, and
defaults for each attribute.
8. Create or combine tables to implement supertype/
subtype structures.
9. Evaluate and specify referential integrity constraints.
Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved
SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Data Types for Different Database Technologies


Logical Data Type Physical Data Type Physical Data Type Physical Data Type
to be stored in field) MS Access Microsoft SQL Server Oracle

Fixed length character data TEXT CHAR (size) or CHAR (size)


(use for fields with relatively character (size)
fixed length character data)
Variable length character data TEXT VARCHAR (max size) or VARCHAR (max size)
(use for fields that require character varying (max
character data but for which size)
size varies greatly--such as
ADDRESS)
Very long character data (use MEMO TEXT LONG VARCHAR or
for long descriptions and LONG VARCHAR2
notes--usually no more than
one such field per record)
Integer number NUMBER INT (size) or INTEGER (size) or
integer or NUMBER (size)
smallinteger or
tinuinteger
Decimal number NUMBER DECIMAL (size, decimal DECIMAL (size, decimal
places) or places) or
NUMERIC (size, decimal NUMERIC (size, decimal
places) places) or
NUMBER

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Data Types for Different Database Technologies (cont.)

Logical Data Type Physical Data Type Physical Data Type Physical Data Type
to be stored in field) MS Access Microsoft SQL Server Oracle

Financial Number CURRENCY MONEY see decimal number


Date (with time) DATE/TIME DATETIME or DATE
SMALLDATETIME
Depending on precision
needed
Current time (use to store the not supported TIMESTAMP not supported
data and time from the
computer’s system clock)
Yes or No; or True or False YES/NO BIT use CHAR(1) and set a yes
or no domain

Image OLE OBJECT IMAGE LONGRAW


Hyperlink HYPERLINK VARBINARY RAW
Can designer define new data NO YES YES
types?

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Logical data Model in Third Normal Form

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Physical Database Schema


tbl = table
col = column

Physical data
types are
resolved

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Database Integrity

• Key integrity – Primary key is unique and never null.


• Domain integrity – Ensure all field values valid
(within range)
• Referential integrity – Ensure that a foreign key
value in one table has a matching primary key value in
the related table
– Options if a record in one table is deleted:
• No restriction – just do the delete, no integrity
• Delete: cascade – delete all related records in other tables
• Delete: restrict – disallow until all matching records are
deleted
• Delete: set null – set foreign keys of any related records to
“null”

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved


SYSTEMS ANALYSIS AND DESIGN METHODS 6th Edition Whitten Bentley Dittman

Database Distribution and Replication


Data distribution analysis establishes which business locations
need access to which logical data entities and attributes.
– Centralization
• Entire database on a single server in one physical location
– Horizontal distribution (partitioning)
• Tables or rows in a table assigned to different database
servers/locations.
• Efficient local access and security
• Inefficient and complex global access and security
– Vertical distribution (partitioning)
• Columns of tables assigned to different databases servers
• Similar advantages and disadvantages of horizontal distribution
– Replication
• Data duplicated in multiple locations
• DBMS coordinates the update and synchronization of data
• Performance and accessibility advantages
• Increases complexity of maintaining integrity

Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved

Anda mungkin juga menyukai