Top Banner
Chapter 6 Physical Database Design
54

Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Dec 17, 2015

Download

Documents

Gwendolyn Tyler
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: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Chapter 6Chapter 6

Physical Database Design

Physical Database Design

Page 2: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Physical DesignPhysical Design

The purpose of the physical design process is to translate the logical description of the data into technical specifications for storing and retrieving data

Goal: create a design that will provide adequate performance and insure database integrity, security, and recoverability

Decisions made in this phase have a major impact on data accessibility, response times, security, and user friendliness.

The purpose of the physical design process is to translate the logical description of the data into technical specifications for storing and retrieving data

Goal: create a design that will provide adequate performance and insure database integrity, security, and recoverability

Decisions made in this phase have a major impact on data accessibility, response times, security, and user friendliness.

Page 3: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Required InputsRequired Inputs Normalized relationsNormalized relations

Data volume and use estimatesData volume and use estimates

Attribute definitionsAttribute definitions

Descriptions of where and when data are usedDescriptions of where and when data are used

Expectations for response time, data security, Expectations for response time, data security, backup, recovery, retention, and integritybackup, recovery, retention, and integrity

Description of chosen technologyDescription of chosen technology

Normalized relationsNormalized relations

Data volume and use estimatesData volume and use estimates

Attribute definitionsAttribute definitions

Descriptions of where and when data are usedDescriptions of where and when data are used

Expectations for response time, data security, Expectations for response time, data security, backup, recovery, retention, and integritybackup, recovery, retention, and integrity

Description of chosen technologyDescription of chosen technology

Page 4: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Determining volume and usageDetermining volume and usage

Data volumeData volume statistics represent the size of statistics represent the size of the businessthe business

• calculated assuming business growth over a calculated assuming business growth over a period of several yearsperiod of several years

Usage Usage is estimated from the timing of is estimated from the timing of events, transaction volumes, and reporting events, transaction volumes, and reporting and query activity.and query activity.

• Less precise than volume statisticsLess precise than volume statistics

Data volumeData volume statistics represent the size of statistics represent the size of the businessthe business

• calculated assuming business growth over a calculated assuming business growth over a period of several yearsperiod of several years

Usage Usage is estimated from the timing of is estimated from the timing of events, transaction volumes, and reporting events, transaction volumes, and reporting and query activity.and query activity.

• Less precise than volume statisticsLess precise than volume statistics

Page 5: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Composite usage map (Pine Valley Furniture Company)

Composite usage map (Pine Valley Furniture Company)

Page 6: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Physical Design DecisionsPhysical Design Decisions Specify the Specify the data typedata type for each attribute from the logical data for each attribute from the logical data

modelmodel

• minimize storage space and maximize integrityminimize storage space and maximize integrity

Specify Specify physical recordsphysical records by grouping attributes from the logical by grouping attributes from the logical data model data model

Specify the Specify the file organizationfile organization technique to use for physical storage technique to use for physical storage of data recordsof data records

Specify Specify indexesindexes to optimize data retrieval to optimize data retrieval

Specify Specify query optimizationquery optimization strategies strategies

Specify the Specify the data typedata type for each attribute from the logical data for each attribute from the logical data modelmodel

• minimize storage space and maximize integrityminimize storage space and maximize integrity

Specify Specify physical recordsphysical records by grouping attributes from the logical by grouping attributes from the logical data model data model

Specify the Specify the file organizationfile organization technique to use for physical storage technique to use for physical storage of data recordsof data records

Specify Specify indexesindexes to optimize data retrieval to optimize data retrieval

Specify Specify query optimizationquery optimization strategies strategies

Page 7: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Data FormatData Format

Data type selection goalsData type selection goals

• minimize storageminimize storage

• represent all possible valuesrepresent all possible values

– eliminate illegal valueseliminate illegal values

• improve integrityimprove integrity

• support manipulationsupport manipulation

Note: these have different relative importanceNote: these have different relative importance

Data type selection goalsData type selection goals

• minimize storageminimize storage

• represent all possible valuesrepresent all possible values

– eliminate illegal valueseliminate illegal values

• improve integrityimprove integrity

• support manipulationsupport manipulation

Note: these have different relative importanceNote: these have different relative importance

Page 8: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Data format decisions (coding)Data format decisions (coding)

e.g., e.g., AHAH(Adams Hall), (Adams Hall), BB(Buchanan) , etc (Buchanan) , etc

implement by creating a look-up tableimplement by creating a look-up table

there is a trade-off in that you must create and store a there is a trade-off in that you must create and store a second table and you must access this table to look second table and you must access this table to look up the code valueup the code value

consider using when a field has a limited number of consider using when a field has a limited number of possible values, each of which occupies a relatively possible values, each of which occupies a relatively large amount of space, and the number of records is large amount of space, and the number of records is large and/or the number of record accesses is smalllarge and/or the number of record accesses is small

e.g., e.g., AHAH(Adams Hall), (Adams Hall), BB(Buchanan) , etc (Buchanan) , etc

implement by creating a look-up tableimplement by creating a look-up table

there is a trade-off in that you must create and store a there is a trade-off in that you must create and store a second table and you must access this table to look second table and you must access this table to look up the code valueup the code value

consider using when a field has a limited number of consider using when a field has a limited number of possible values, each of which occupies a relatively possible values, each of which occupies a relatively large amount of space, and the number of records is large amount of space, and the number of records is large and/or the number of record accesses is smalllarge and/or the number of record accesses is small

Page 9: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Example code-look-up table (Pine Valley Furniture Company)

Example code-look-up table (Pine Valley Furniture Company)

Page 10: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Data Format decisions (integrity)Data Format decisions (integrity)Data integrity controlsData integrity controls

• default valuedefault value

• Range controlRange control

• Null value controlNull value control

• Referential integrityReferential integrity

Missing dataMissing data

• substitute an estimatesubstitute an estimate

• report missing datareport missing data

• Sensitivity testingSensitivity testing

Data integrity controlsData integrity controls

• default valuedefault value

• Range controlRange control

• Null value controlNull value control

• Referential integrityReferential integrity

Missing dataMissing data

• substitute an estimatesubstitute an estimate

• report missing datareport missing data

• Sensitivity testingSensitivity testing

Page 11: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

For example...For example...

Suppose you were designing the age field in Suppose you were designing the age field in a student record at your university. What a student record at your university. What decisions would you make about:decisions would you make about:

• data typedata type

• integrity (range, default, null)integrity (range, default, null)

• How might your decision vary by other How might your decision vary by other characteristics about the student such as degree characteristics about the student such as degree sought?sought?

Suppose you were designing the age field in Suppose you were designing the age field in a student record at your university. What a student record at your university. What decisions would you make about:decisions would you make about:

• data typedata type

• integrity (range, default, null)integrity (range, default, null)

• How might your decision vary by other How might your decision vary by other characteristics about the student such as degree characteristics about the student such as degree sought?sought?

Page 12: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Attribute groupings

Physical RecordPhysical Record: A group of fields stored in : A group of fields stored in adjacent memory locations and retrieved adjacent memory locations and retrieved together as a unit. together as a unit.

PagePage: The amount of data read or written in : The amount of data read or written in one I/O operation.one I/O operation.

Blocking FactorBlocking Factor: The number of physical : The number of physical records per page.records per page.

Page 13: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Database Access ModelDatabase Access Model

The goal in structuring physical records is to minimize performance bottlenecks resulting from disk accesses (accessing data from disk is

slow compared to main memory)

Page 14: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Attribute grouping:Denormalization

Attribute grouping:Denormalization

Process of transforming normalized Process of transforming normalized relations into denormalized physical record relations into denormalized physical record specificationsspecifications

• may partition a relation into more than one may partition a relation into more than one physical recordphysical record

• may combine attributes from different relations may combine attributes from different relations into one physical recordinto one physical record

Process of transforming normalized Process of transforming normalized relations into denormalized physical record relations into denormalized physical record specificationsspecifications

• may partition a relation into more than one may partition a relation into more than one physical recordphysical record

• may combine attributes from different relations may combine attributes from different relations into one physical recordinto one physical record

Page 15: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

DenormalizationDenormalizationInvolves a trade-off:Involves a trade-off:

Reduced disk accesses and greater performance (due, for Reduced disk accesses and greater performance (due, for example, to fewer table joins)example, to fewer table joins)

- But -- But -

Introduction of anomalies (and thus redundancies) that Introduction of anomalies (and thus redundancies) that will necessitate extra data maintenancewill necessitate extra data maintenance

increase chance of errors and force reprogramming when increase chance of errors and force reprogramming when business rules changebusiness rules change

may optimize certain tasks at the expense of others (if may optimize certain tasks at the expense of others (if activities change, benefits may no longer exist)activities change, benefits may no longer exist)

Involves a trade-off:Involves a trade-off:

Reduced disk accesses and greater performance (due, for Reduced disk accesses and greater performance (due, for example, to fewer table joins)example, to fewer table joins)

- But -- But -

Introduction of anomalies (and thus redundancies) that Introduction of anomalies (and thus redundancies) that will necessitate extra data maintenancewill necessitate extra data maintenance

increase chance of errors and force reprogramming when increase chance of errors and force reprogramming when business rules changebusiness rules change

may optimize certain tasks at the expense of others (if may optimize certain tasks at the expense of others (if activities change, benefits may no longer exist)activities change, benefits may no longer exist)

Page 16: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Denormalization opportunitiesDenormalization opportunities

1:1 relationship1:1 relationship

M:M associative entity with non-key M:M associative entity with non-key attributesattributes

reference datareference data

1:1 relationship1:1 relationship

M:M associative entity with non-key M:M associative entity with non-key attributesattributes

reference datareference data

Page 17: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

A possible denormali-zation situation: reference data

Page 18: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

More denormalization options

Horizontal PartitioningHorizontal Partitioning: Distributing the : Distributing the rows of a table into several separate files.rows of a table into several separate files.

Vertical PartitioningVertical Partitioning: Distributing the : Distributing the columns of a table into several separate columns of a table into several separate files.files.

• The primary key must be repeated in each file.The primary key must be repeated in each file.

Combination of bothCombination of both

Page 19: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Partitioning AdvantagesAdvantages of Partitioning: of Partitioning:

• Records used together are grouped togetherRecords used together are grouped together

• Each partition can be optimized for performanceEach partition can be optimized for performance

• Security and recoverySecurity and recovery

• Partitions stored on different disks: less contentionPartitions stored on different disks: less contention

• Parallel processing capabilityParallel processing capability

DisadvantagesDisadvantages of Partitioning: of Partitioning:

• Slower retrievals when across partitionsSlower retrievals when across partitions

• Complexity for application programmersComplexity for application programmers

• Anomalies and extra storage space requirements due to Anomalies and extra storage space requirements due to duplication of data across partitionsduplication of data across partitions

Page 20: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

How about this..How about this..

Consider the following normalized relations:Consider the following normalized relations:

STORE(STORE(Store_IdStore_Id, Region, Manager_Id, Square_Feet), Region, Manager_Id, Square_Feet)

EMPLOYEE(EMPLOYEE(Emp_IdEmp_Id, Store_Id, Name, Address), Store_Id, Name, Address)

DEPARTMENT(DEPARTMENT(Dept#,Dept#, Store_ID, Manager_Id, Store_ID, Manager_Id, Sales_Goal)Sales_Goal)

SCHEDULE(SCHEDULE(Dept#Dept#, , Emp_IdEmp_Id, , DateDate, hours), hours)

What opportunities might exist for denormalization?What opportunities might exist for denormalization?

Consider the following normalized relations:Consider the following normalized relations:

STORE(STORE(Store_IdStore_Id, Region, Manager_Id, Square_Feet), Region, Manager_Id, Square_Feet)

EMPLOYEE(EMPLOYEE(Emp_IdEmp_Id, Store_Id, Name, Address), Store_Id, Name, Address)

DEPARTMENT(DEPARTMENT(Dept#,Dept#, Store_ID, Manager_Id, Store_ID, Manager_Id, Sales_Goal)Sales_Goal)

SCHEDULE(SCHEDULE(Dept#Dept#, , Emp_IdEmp_Id, , DateDate, hours), hours)

What opportunities might exist for denormalization?What opportunities might exist for denormalization?

Page 21: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Physical Files Physical File: A file as stored on diskPhysical File: A file as stored on disk

Constructs to link two pieces of data:Constructs to link two pieces of data:

• Sequential storageSequential storage

• PointersPointers

File OrganizationFile Organization: How the files are arranged on the disk : How the files are arranged on the disk (more on this later)(more on this later)

Access MethodAccess Method: How the data can be retrieved based on : How the data can be retrieved based on the file organizationthe file organization

• Relative - data accessed as an offset from the most Relative - data accessed as an offset from the most recently referenced point in secondary memoryrecently referenced point in secondary memory

• Direct - data accessed as a result of a calculation to Direct - data accessed as a result of a calculation to generate the beginning address of a recordgenerate the beginning address of a record

Page 22: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

File OrganizationsFile Organizations A technique for physically arranging the records of a file A technique for physically arranging the records of a file

on secondary storage devices.on secondary storage devices. Goals in selecting:Goals in selecting: ((trade-offstrade-offs exist, of course) exist, of course)

• Fast data retrievalFast data retrieval

• High throughput for input and maintenanceHigh throughput for input and maintenance

• Efficient use of storage spaceEfficient use of storage space

• Protection from failures or data lossProtection from failures or data loss

• Minimal need for reorganizationMinimal need for reorganization

• Accommodation for growthAccommodation for growth

• Security from unauthorized useSecurity from unauthorized use

A technique for physically arranging the records of a file A technique for physically arranging the records of a file on secondary storage devices.on secondary storage devices.

Goals in selecting:Goals in selecting: ((trade-offstrade-offs exist, of course) exist, of course)

• Fast data retrievalFast data retrieval

• High throughput for input and maintenanceHigh throughput for input and maintenance

• Efficient use of storage spaceEfficient use of storage space

• Protection from failures or data lossProtection from failures or data loss

• Minimal need for reorganizationMinimal need for reorganization

• Accommodation for growthAccommodation for growth

• Security from unauthorized useSecurity from unauthorized use

Page 23: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

File OrganizationsFile Organizations

Sequential

Indexed

• Indexed Sequential

• Indexed Nonsequential

Hashed (also called Direct)

See Table 6-3 for comparison

Sequential

Indexed

• Indexed Sequential

• Indexed Nonsequential

Hashed (also called Direct)

See Table 6-3 for comparison

Page 24: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Sequential File Organization

Records of the file are stored in sequence by the primary key field values

Page 25: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Comparisons of file organizations:

(a) Sequential

Page 26: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Sequential RetrievalSequential Retrieval Consider a file of 10,000 records each occupying 1 pageConsider a file of 10,000 records each occupying 1 page

Queries that require processing all records will require Queries that require processing all records will require 10,000 accesses10,000 accesses

e.g., Find all items of type 'E'e.g., Find all items of type 'E'

Many disk accesses are wasted if few records meet the Many disk accesses are wasted if few records meet the conditioncondition

However, very effective if most or all records will be However, very effective if most or all records will be accessed (e.g., payroll)accessed (e.g., payroll)

Consider a file of 10,000 records each occupying 1 pageConsider a file of 10,000 records each occupying 1 page

Queries that require processing all records will require Queries that require processing all records will require 10,000 accesses10,000 accesses

e.g., Find all items of type 'E'e.g., Find all items of type 'E'

Many disk accesses are wasted if few records meet the Many disk accesses are wasted if few records meet the conditioncondition

However, very effective if most or all records will be However, very effective if most or all records will be accessed (e.g., payroll)accessed (e.g., payroll)

Page 27: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Indexed File Organization

Index concept is like index in a book

Indexed-sequential file organization: The records are stored sequentially by primary key values and there is an index built on the primary key field (and possibly indexes built on other fields, also)

Page 28: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

(b) Indexed

Page 29: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Hashed File Organization

Hashing Algorithm: Converts a primary

key value into a record address

Division-remainder method is common

hashing algorithm(more to come on this)

Page 30: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

(c ) Hashed

Page 31: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

HashingHashing

A technique for reducing disk accesses for A technique for reducing disk accesses for directdirect

accessaccess

Avoids an indexAvoids an index

Number of accesses per record can be close to oneNumber of accesses per record can be close to one

The hash field is converted to a hash address by a The hash field is converted to a hash address by a

hash functionhash function

A technique for reducing disk accesses for A technique for reducing disk accesses for directdirect

accessaccess

Avoids an indexAvoids an index

Number of accesses per record can be close to oneNumber of accesses per record can be close to one

The hash field is converted to a hash address by a The hash field is converted to a hash address by a

hash functionhash function

Page 32: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

HashingHashing

Page 33: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Shortcomings of HashingShortcomings of Hashing

Different hash fields may convert to the same hash Different hash fields may convert to the same hash addressaddress

• these are called Synonymsthese are called Synonyms

• store the colliding record in an overflow areastore the colliding record in an overflow area

Long synonym chains degrade performanceLong synonym chains degrade performance

There can be only one hash field per recordThere can be only one hash field per record

The file can no longer be processed sequentiallyThe file can no longer be processed sequentially

Different hash fields may convert to the same hash Different hash fields may convert to the same hash addressaddress

• these are called Synonymsthese are called Synonyms

• store the colliding record in an overflow areastore the colliding record in an overflow area

Long synonym chains degrade performanceLong synonym chains degrade performance

There can be only one hash field per recordThere can be only one hash field per record

The file can no longer be processed sequentiallyThe file can no longer be processed sequentially

Page 34: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

ClusteringClustering

In some relational DBMS, related records from In some relational DBMS, related records from different tables that are often retrieved together different tables that are often retrieved together can be stored close together on diskcan be stored close together on disk

Because the related records are stored close to one Because the related records are stored close to one another on the physical disk, less time is needed to another on the physical disk, less time is needed to retrieve the dataretrieve the data

• E.g., Customer data and Order data may frequently be E.g., Customer data and Order data may frequently be retrieved togetherretrieved together

Can require substantial maintenance if the Can require substantial maintenance if the clustered data changes frequentlyclustered data changes frequently

In some relational DBMS, related records from In some relational DBMS, related records from different tables that are often retrieved together different tables that are often retrieved together can be stored close together on diskcan be stored close together on disk

Because the related records are stored close to one Because the related records are stored close to one another on the physical disk, less time is needed to another on the physical disk, less time is needed to retrieve the dataretrieve the data

• E.g., Customer data and Order data may frequently be E.g., Customer data and Order data may frequently be retrieved togetherretrieved together

Can require substantial maintenance if the Can require substantial maintenance if the clustered data changes frequentlyclustered data changes frequently

Page 35: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

IndexingIndexing

An index is a table file that is used to determine the location of rows in another file that satisfy some condition

An index is a table file that is used to determine the location of rows in another file that satisfy some condition

Page 36: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Querying with an IndexQuerying with an Index

Read the index into memoryRead the index into memory

Search the index to find records meeting the Search the index to find records meeting the

conditioncondition

Access only those records containing required dataAccess only those records containing required data

Disk accesses are substantially reduced when the Disk accesses are substantially reduced when the

query involves few recordsquery involves few records

Read the index into memoryRead the index into memory

Search the index to find records meeting the Search the index to find records meeting the

conditioncondition

Access only those records containing required dataAccess only those records containing required data

Disk accesses are substantially reduced when the Disk accesses are substantially reduced when the

query involves few recordsquery involves few records

Page 37: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Maintaining an IndexMaintaining an Index Adding a record requires at least two disk accesses:

• Update the file

• Update the index

Trade-off:

Faster queries

Slower maintenance (additions, deletions, and updates of records)

• Thus, more static databases benefit more overall

Adding a record requires at least two disk accesses:

• Update the file

• Update the index

Trade-off:

Faster queries

Slower maintenance (additions, deletions, and updates of records)

• Thus, more static databases benefit more overall

Page 38: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Rules of Thumbfor Using Indexes

1. Indexes are most useful on larger tables

2. Index the primary key of each table(may be automatic, as in Access)

3. Indexes are useful on search fields (WHERE)

4. Indexes are also useful on fields used for sorting (ORDER BY) and categorizing (GROUP BY)

5. Most useful to index on a field when there are many different values for that field

Page 39: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Rules of Thumbfor Using Indexes

6. Find out the limits placed on indexing by your DBMS (Access allows 32 indexes per table, and no index may contain more than 10 fields)

7. Depending on the DBMS, null values may not be referenced from an index (thus, rows with a null value in the field that is indexed may not be found by a search using the index)

Page 40: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Rules for Adding Derived ColumnsRules for Adding Derived Columns

Use when aggregate values are regularly Use when aggregate values are regularly retrieved.retrieved.

Use when aggregate values are costly to Use when aggregate values are costly to calculate.calculate.

Permit updating only of source data.Permit updating only of source data.

Create triggers to cascade changes from Create triggers to cascade changes from source data.source data.

Use when aggregate values are regularly Use when aggregate values are regularly retrieved.retrieved.

Use when aggregate values are costly to Use when aggregate values are costly to calculate.calculate.

Permit updating only of source data.Permit updating only of source data.

Create triggers to cascade changes from Create triggers to cascade changes from source data.source data.

Page 41: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

One Other Rule of Thumbfor Increasing PerformanceOne Other Rule of Thumb

for Increasing Performance

Consider contriving a shorter field or selecting another candidate key to substitute for a long, multi-field primary key (and all associated foreign keys)

Consider contriving a shorter field or selecting another candidate key to substitute for a long, multi-field primary key (and all associated foreign keys)

Page 42: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Query Optimizer Factors Type of Query

• Highly selective.

• All or most of the records of a file.

Unique fields

Size of files

Indexes

Join Method

• Nested-Loop

• Merge-Scan (Both files must be ordered or indexed on the join columns.)

Page 43: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

More practiceMore practice Draw a composite usage map for the following:Draw a composite usage map for the following:

• PERSON(person_ID, name, address, DOB)PERSON(person_ID, name, address, DOB)

• PATIENT(PA_person_ID, Contact)PATIENT(PA_person_ID, Contact)

• PHYSICIAN(PH_person_ID, specialty)PHYSICIAN(PH_person_ID, specialty)

• PERFORMANCE(PA_person_ID, PH_person_ID, PERFORMANCE(PA_person_ID, PH_person_ID, Treatment#, Treatment_date, Treatment_time)Treatment#, Treatment_date, Treatment_time)

• CONSUMPTION(PA_person_ID, Item#, Date, Quantity)CONSUMPTION(PA_person_ID, Item#, Date, Quantity)

• ITEM(Item#, Description)ITEM(Item#, Description)

Make recommendations about denormalizing, Make recommendations about denormalizing, partitioning, file organization, and indexingpartitioning, file organization, and indexing

Draw a composite usage map for the following:Draw a composite usage map for the following:

• PERSON(person_ID, name, address, DOB)PERSON(person_ID, name, address, DOB)

• PATIENT(PA_person_ID, Contact)PATIENT(PA_person_ID, Contact)

• PHYSICIAN(PH_person_ID, specialty)PHYSICIAN(PH_person_ID, specialty)

• PERFORMANCE(PA_person_ID, PH_person_ID, PERFORMANCE(PA_person_ID, PH_person_ID, Treatment#, Treatment_date, Treatment_time)Treatment#, Treatment_date, Treatment_time)

• CONSUMPTION(PA_person_ID, Item#, Date, Quantity)CONSUMPTION(PA_person_ID, Item#, Date, Quantity)

• ITEM(Item#, Description)ITEM(Item#, Description)

Make recommendations about denormalizing, Make recommendations about denormalizing, partitioning, file organization, and indexingpartitioning, file organization, and indexing

Page 44: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

RAIDRAID

RRedundant edundant AArrays of rrays of IInexpensive nexpensive DDisksisks

Exploits economies of scale of disk manufacturing for the Exploits economies of scale of disk manufacturing for the

computer marketcomputer market

Can give greater securityCan give greater security

Increases fault tolerance of systemsIncreases fault tolerance of systems

Not a replacement for regular backupNot a replacement for regular backup

RRedundant edundant AArrays of rrays of IInexpensive nexpensive DDisksisks

Exploits economies of scale of disk manufacturing for the Exploits economies of scale of disk manufacturing for the

computer marketcomputer market

Can give greater securityCan give greater security

Increases fault tolerance of systemsIncreases fault tolerance of systems

Not a replacement for regular backupNot a replacement for regular backup

Page 45: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

RAIDRAID

The operating system sees a set of physical drives as The operating system sees a set of physical drives as

one logical driveone logical drive

Data are distributed across physical drivesData are distributed across physical drives

All levels, except 0, have data redundancy or error-All levels, except 0, have data redundancy or error-

correction features correction features

Parity codes or redundant data are used for data Parity codes or redundant data are used for data

recoveryrecovery

The operating system sees a set of physical drives as The operating system sees a set of physical drives as

one logical driveone logical drive

Data are distributed across physical drivesData are distributed across physical drives

All levels, except 0, have data redundancy or error-All levels, except 0, have data redundancy or error-

correction features correction features

Parity codes or redundant data are used for data Parity codes or redundant data are used for data

recoveryrecovery

Page 46: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

MirroringMirroring WriteWrite

• Identical copies of file are written to each drive in arrayIdentical copies of file are written to each drive in array ReadRead

• Alternate pages are read simultaneously from each driveAlternate pages are read simultaneously from each drive

• Pages put together in memoryPages put together in memory

• Access time is reduced by approximately the number of disks in the arrayAccess time is reduced by approximately the number of disks in the array Read errorRead error

• Read required page from another driveRead required page from another drive TradeoffsTradeoffs

Provides data securityProvides data security Reduces access timeReduces access time Uses more disk spaceUses more disk space

WriteWrite

• Identical copies of file are written to each drive in arrayIdentical copies of file are written to each drive in array ReadRead

• Alternate pages are read simultaneously from each driveAlternate pages are read simultaneously from each drive

• Pages put together in memoryPages put together in memory

• Access time is reduced by approximately the number of disks in the arrayAccess time is reduced by approximately the number of disks in the array Read errorRead error

• Read required page from another driveRead required page from another drive TradeoffsTradeoffs

Provides data securityProvides data security Reduces access timeReduces access time Uses more disk spaceUses more disk space

Page 47: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

MirroringMirroring

Complete Data Set

Complete Data Set

No parity

Page 48: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

StripingStriping Three drive modelThree drive model WriteWrite

• Half of file to first driveHalf of file to first drive

• Half of file to second driveHalf of file to second drive

• Parity bit to third driveParity bit to third drive ReadRead

• Portions from each drive are put together in memoryPortions from each drive are put together in memory Read errorRead error

• Lost bits are reconstructed from third drive’s parity dataLost bits are reconstructed from third drive’s parity data TradeoffsTradeoffs

Provides data securityProvides data security Uses less storage space than mirroringUses less storage space than mirroring Not as fast as mirroringNot as fast as mirroring

Three drive modelThree drive model WriteWrite

• Half of file to first driveHalf of file to first drive

• Half of file to second driveHalf of file to second drive

• Parity bit to third driveParity bit to third drive ReadRead

• Portions from each drive are put together in memoryPortions from each drive are put together in memory Read errorRead error

• Lost bits are reconstructed from third drive’s parity dataLost bits are reconstructed from third drive’s parity data TradeoffsTradeoffs

Provides data securityProvides data security Uses less storage space than mirroringUses less storage space than mirroring Not as fast as mirroringNot as fast as mirroring

Page 49: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

StripingStriping

One-Half Data Set

One-Half Data Set

Parity Codes

Page 50: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Database Architectures

Hierarchical

Network

Relational

Object-oriented

Multidimensional

Page 51: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Hierarchical modelsHierarchical models

Type of logical database model in which data is organized in a tree structure.

Records are divided into segments which are linked using pointers.

Parent and child data are stored together.

Type of logical database model in which data is organized in a tree structure.

Records are divided into segments which are linked using pointers.

Parent and child data are stored together.

Page 52: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Sample hierarchical modelSample hierarchical model

ROOT/PARENT

FIRST CHILD

2nd CHILD

RatingsRatings SalarySalary

CompensationCompensation JobJobAssignmentsAssignments

PensionPension InsuranceInsurance HealthHealth

BenefitsBenefits

EmployeeEmployee

Page 53: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Network modelNetwork model

Extends the hierarchical model by allowing a child to have zero, one, or many parents

No real theoretical base

Never widely used

Extends the hierarchical model by allowing a child to have zero, one, or many parents

No real theoretical base

Never widely used

STUDENTA

STUDENTB

STUDENTC

CLASS1

CLASS2

Page 54: Chapter 6 Physical Database Design. Physical Design u The purpose of the physical design process is to translate the logical description of the data into.

Comparing the alternativesComparing the alternatives

Hierarchical Network Relational OO

Efficiency High Medium-high

Lower Lower

Flexibility Low Low-medium

High High

Ease ofuse

Low Low-medium

High High**

Relation-shipsupported

1:M M:M 1:1, 1:M all

Hierarchical Network Relational OO

Efficiency High Medium-high

Lower Lower

Flexibility Low Low-medium

High High

Ease ofuse

Low Low-medium

High High**

Relation-shipsupported

1:M M:M 1:1, 1:M all

** OODBS are marketed as easy to use, but the transition from RDBMS is difficult