Top Banner
11-1 © Prentice Hall, 2007 Chapter 11: Chapter 11: Physical Database Physical Database Design Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer
49

11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Jan 02, 2016

Download

Documents

Allan Phillips
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

11-1© Prentice Hall, 2007

Chapter 11:Chapter 11:Physical Database DesignPhysical Database Design

Object-Oriented Systems Analysis and Design

Joey F. George, Dinesh Batra,

Joseph S. Valacich, Jeffrey A. Hoffer

Page 2: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-2© Prentice Hall, 2007

Chapter ObjectivesChapter Objectives

After studying this chapter you should be able to:– Design database fields.– Evaluate denormalization situations.– Design file organization structures.– Design object-relational features.

Page 3: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-3© Prentice Hall, 2007

Page 4: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-4© Prentice Hall, 2007

What Is Physical Database What Is Physical Database Design?Design?

The part of a database design that deals with efficiency considerations for access of data

Processing speed, storage space, and data manipulation are key issues in physical database design

Page 5: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-5© Prentice Hall, 2007

Sometimes, the analyst and the designer are the same person,

Deliverables

Page 6: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-6© Prentice Hall, 2007

Page 7: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-7© Prentice Hall, 2007

What Is SQL?What Is SQL?

Structured Query Language

Often pronounced “sequel”

The standard language for creating and using relational databases

ANSI Standards– SQL-92 – most commonly available– SQL-99 – included object-relational features

Page 8: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-8© Prentice Hall, 2007

Common SQL CommandsCommon SQL Commands

CREATE TABLE – used to define table structures and link tables together

SELECT – used to retrieve data using specified formats and selection criteria

INSERT – used to add new rows to a table

UPDATE – used to modify data in existing table rows

DELETE – used to remove rows from tables

Page 9: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-9© Prentice Hall, 2007

Example CREATE TABLE Example CREATE TABLE StatementStatement

Here, a table called DEPT is created, with one numeric and two text fields.

The numeric field is the primary key.

Page 10: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-10© Prentice Hall, 2007

Example INSERT StatementExample INSERT Statement This statement inserts a new row into the DEPT

table

DEPTNO’s value is 50 DNAME’s value is “DESIGN” LOC’s value is “MIAMI”

Page 11: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-11© Prentice Hall, 2007

SELECTSELECTThe SELECT, and FROM clauses are required.

All others are optional.

WHERE is used very commonly.

Page 12: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-12© Prentice Hall, 2007

Page 13: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-13© Prentice Hall, 2007

SELECT Statement: Example 1SELECT Statement: Example 1

Select * from DEPT;

Result: all fields of all rows in the DEPT table

Page 14: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-14© Prentice Hall, 2007

SELECT Statement: Example 2SELECT Statement: Example 2

Select * from EMP where ENAME = ‘SMITH’;

Result: all fields for employee “Smith”

Page 15: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-15© Prentice Hall, 2007

SELECT Statement: Example 3SELECT Statement: Example 3

Select EMPNO, ENAME From EMP where JOB = ‘SALESMAN’ order by ENAME;

Result: employee number, name and job for only salesmen from the EMP table, sorted by name

Page 16: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-16© Prentice Hall, 2007

What Is a Join Query?What Is a Join Query?

A query in which the WHERE clause includes a match of primary key and foreign key values between tables that share a relationship

Page 17: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-17© Prentice Hall, 2007

SELECT Statement: Example 4SELECT Statement: Example 4

Select EMPNO, ENAME, DNAME from EMP, DEPT where EMP.DEPT_NO = DEPT.DEPT_NO and DEPT.LOC = ‘CHICAGO’;

Result: all employees’ number and name (from the EMP table, and their associated department names, obtained by joining the tables based on DEPT_NO.

Only employees housed in department located in Chicago will be included

Page 18: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-18© Prentice Hall, 2007

SELECT Statement: Example 4SELECT Statement: Example 4(cont.)(cont.)

Join queries almost always involve matching the primary key of the dominant table with the foreign key of the dependent table.

Page 19: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-19© Prentice Hall, 2007

What Is an Aggregation Query?What Is an Aggregation Query?

A query results in summary information about a group of records, such as sums, counts, or averages

These involve aggregate functions in the SELECT clause (SUM, AVG, COUNT)

Aggregations can be filtered using the HAVING clause and/or grouped using the GROUP BY clause

Page 20: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-20© Prentice Hall, 2007

SELECT Statement: Example 5SELECT Statement: Example 5

Select JOB, Avg(SALARY) from EMP Group by JOB Having Avg(SALARY) >= 3000;

The job name and average salary for each job of employees in the EMP table.

Only jobs with average salaries exceeding $3000 will be included

Page 21: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-21© Prentice Hall, 2007

SELECT Statement: Example 5SELECT Statement: Example 5(cont.)(cont.)

Note that clerks and salesmen are not included, because the average salaries for these jobs are below $3000.

Page 22: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-22© Prentice Hall, 2007

Example Data ManipulationExample Data Manipulation

Update EMP set SAL = 3000 where EMPNO = 7698;– Modifies the existing employee’s (7698) salary

Delete from EMP where EMPNO = 7844– Removes employee 7844 from the EMP table

Page 23: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-23© Prentice Hall, 2007

1. Designing Fields1. Designing FieldsField – the smallest unit of named application data

recognized by system software such as a DBMS

Fields map roughly onto attributes in conceptual data models

Field design involves consideration of identity, data types, sizes, and constraints

Page 24: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-24© Prentice Hall, 2007

Data type –A coding scheme recognized by system software for representing organizational data

Page 25: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-25© Prentice Hall, 2007

Considerations for Choosing Considerations for Choosing Data TypesData Types

Balance these four objectives:

1. Minimize storage space

2. Represent all possible values of the field

3. Improve data integrity for the field

4. Support all data manipulations desired for the field

Page 26: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-26© Prentice Hall, 2007

Mapping a composite attribute onto multiple fields with various data types

Page 27: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-27© Prentice Hall, 2007

Creating and Using Composite Creating and Using Composite Attribute TypesAttribute Types

Page 28: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-28© Prentice Hall, 2007

Data Integrity ControlsData Integrity Controls

Default Values – used if no explicit value is entered

Format Controls – restricts data entry values in specific character positions

Range Controls – forces values to be among an acceptable set of values

Referential Integrity – forces foreign keys to align with primary keys

Null Value Controls – determines whether fields can be empty of value

Page 29: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-29© Prentice Hall, 2007

Referential integrity is important for ensuring that data relationships are accurate and consistent

Page 30: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-30© Prentice Hall, 2007

2. What Is Denormalization?2. What Is Denormalization?The process of combining normalized

relations into physical tables based on affinity of use of rows and fields, and on retrieval and update frequencies on the tables

Results in better speed of access, but reduces data integrity and increases data redundancy

Page 31: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-31© Prentice Hall, 2007

This will result in null values in several rows’ application data.

Page 32: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-32© Prentice Hall, 2007

Page 33: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-33© Prentice Hall, 2007

This will result in duplications of item descriptions in several rows of the CanSupplyDR table.

Page 34: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-34© Prentice Hall, 2007

Duplicate regionManager data

Page 35: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-35© Prentice Hall, 2007

3. What Is a File Organization?3. What Is a File Organization?

A technique for physically arranging the row objects of a file

Main purpose of file organization is to optimize speed of data access and modification

Page 36: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-36© Prentice Hall, 2007

Page 37: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-37© Prentice Hall, 2007

Secondary Storage ConceptsSecondary Storage Concepts

Block – a unit of data retrieval from secondary storage

Extent – a set of contiguous blocksScan – a complete read of a file block by

blockBlocking factor – the number of row objects

that fit in one block

Page 38: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-38© Prentice Hall, 2007

Determining Table Scan TimeDetermining Table Scan Time

Block read time is determined by seek, rotation and transfer.

Average table scan time equals #rows in table divided by blocking factor multiplied by block read time

Page 39: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-39© Prentice Hall, 2007

What Is a Heap?What Is a Heap?

A file with no organization

Requires full table scan for data retrieval

Only use this for small, cacheable tables

Page 40: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-40© Prentice Hall, 2007

What Is Hashing?What Is Hashing?A technique that uses an algorithm to

convert a key value to a row address

Useful for random access, but not for sequential access

Page 41: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-41© Prentice Hall, 2007

What Is an Indexed File What Is an Indexed File Organization?Organization?

A storage structure involving indexes, which are key values and pointers to row addresses

Indexed file organizations are structured to enable fast random and sequential access

Index files are fast for queries, but require additional overhead for inserts, deletes, and updates

Page 42: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-42© Prentice Hall, 2007

Random Access Processing Using B+ Tree IndexesRandom Access Processing Using B+ Tree Indexes

Indexes are usually implemented as B+ trees

These are balanced trees, which preserve a sequential ascending order of items as they are added.

Page 43: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-43© Prentice Hall, 2007

Issues to Consider When Issues to Consider When Selecting a File OrganizationSelecting a File Organization

File sizeFrequency of data retrievalsFrequency of updatesFactors related to primary and foreign keysFactors related to non-key attributes

Page 44: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-44© Prentice Hall, 2007

Which Fields should be Indexed?Which Fields should be Indexed?

Page 45: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-45© Prentice Hall, 2007

4. Design of Object Relational 4. Design of Object Relational FeaturesFeatures

Object-relatonal databases support:– Generalization and inheritance– Aggregation– Mulivalued attributes– Object identifiers– Relationships by reference (pointers)

Page 46: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-46© Prentice Hall, 2007

Generalization in Oracle 9i/10gGeneralization in Oracle 9i/10g

Page 47: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-47© Prentice Hall, 2007

Aggregation in Oracle 9i/10gAggregation in Oracle 9i/10g

Page 48: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-48© Prentice Hall, 2007

Multivalued Attributes in Oracle 9i/10gMultivalued Attributes in Oracle 9i/10g

Page 49: 11-1 © Prentice Hall, 2007 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,

Chapter 11 11-49© Prentice Hall, 2007

Object Identifiers in Oracle 9i/10gObject Identifiers in Oracle 9i/10g