49
Chapter 10 Designing the Files and Databases

Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

Embed Size (px)

Citation preview

Page 1: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

Chapter 10

Designing the Files and Databases

Page 2: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 2

Learning Objectives Discuss the conversion from a

logical data model to a physical database schema

Understand the issues related to the physical design of fields, records, and files

Identify the common file types and their applications

Page 3: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 3

Learning Objectives Understand the concepts of data

integrity and referential integrity, and the various methods available as controls

Identify the basic characteristics of the four common database architectures

Page 4: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 4

File and Database Design Goals

The accurate translation of the logical relations into a technical specification

Specifying the storage requirements and technologies for all data to be contained in the system

Page 5: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 5

Designing and Specifying Fields

Data Attribute The smallest unit specified in the

logical model Field

The smallest unit specified in the physical model

Page 6: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 6

Field Types Primary Key Foreign Key Non-key

Page 7: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 7

Figure 10-1. Common Field Types

Customer ID LastName FirstName Address City State Zipcode

Order ID Customer ID OrderDate

Primary KeyDescriptive

Fields

Foreign Key

Page 8: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 8

Data Types A detailed specification of the

fields

Primitive Data Type User-Defined Data Type

Page 9: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 9

Table 10-1. Common Data Type Definitions

Page 10: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 10

Field Representation The process of determining how

each field must be recorded in the data dictionary

Examples: Ownership of the data element Coding method for data values Procedures for handling missing data

values

Page 11: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 11

Table 10-2. Common Field-Level Data Specifications

Page 12: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 12

Calculated Field Values Compute-on-demand

The calculated field is represented in the data dictionary but not stored in the file

Recalculate-on-demand The field actually contains a value, but

it is not recomputed unless there is a change in the values used to calculate it

Page 13: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 13

Data Integrity Key Integrity Domain Integrity Referential Integrity

Page 14: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 14

Key Integrity Ensure every file has a unique

primary key Prevent any two records from

having the same primary key value Primary key field must never be

allowed to have a null value

Page 15: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 15

Domain Integrity Ensure no data element value in a

file or database is outside its range Any control imposed on a field will

always be imposed on data entered or stored in that field, no matter what the circumstances

Page 16: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 16

Table 10-3. Common Domain Controls

Page 17: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 17

Figure 10-2. Example of Referential Integrity Between Files

CUSTOMER (Customer ID, LastName, FirstName, Address, City, State, Zipcode)

ORDER (Order ID, Customer ID, OrderDate)

Page 18: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 18

Referential Integrity Exists when the foreign key value

in one file has no matching primary key value in another related file

Deletion rules (Table 10-4)

Page 19: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 19

Table 10-4. Example of Referential Integrity Deletion Rules

Page 20: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 20

Figure 10-3. Examples of Proper and Improper Field Sequencing

Customer ID State Address LastName Zipcode City FirstName

Customer ID LastName FirstName Address City State Zipcode

IMPROPER

PROPER

Page 21: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 21

Record Length Fixed-length record

All records have exactly the same number of bytes

Variable-length record Each record contains a variable

number of bytes

Page 22: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 22

Figure 10-4. Fixed Length Record With Provision For Multiple Vendors

Field Number Field Identifier1 Product ID2 Description3 Qty On Hand4 Qty On Order5 Reorder Qty6 Vendor ID7 Vendor Unit Price8 Vendor Price Break Qty9 Vendor ID

10 Vendor Unit Price11 Vendor Price Break Qty12 Vendor ID13 Vendor Unit Price14 Vendor Price Break Qty

Potentially

Wasted

Storage

Space

Page 23: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 23

Figure 10-5. Variable Length Record With Provision For Multiple Vendors

Field Number Field Identifier1 Product ID2 Description3 Qty On Hand4 Qty On Order5 Reorder Qty6 Number of Listed Vendors9 Vendor ID

10 Vendor Unit Price11 Vendor Price Break Qty

Indicator for number of

Vendor Fields

Page 24: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 24

Paging and Blocking Page

The actual amount of data read or written into memory

Page size The total amount of memory

allocated Blocking factor

The number of records stored or retrieved for a given query

Page 25: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 25

Figure 10-6. Example of Data Stored With and Without Blocking

Record1

Sector Without Blocking Unused Storage Space

Record5

Record4

Record3

Record2

Record1

512 bytes

SectorWith

Blocking

Page 26: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 26

Figure 10-7. Record Spanning Approach

Sector 1 Unused Storage Space

512 bytes

Sector 2

Record5

Record4

Record3

Record2

Record1

Record6

Part 1

Record10

Record9

Record8

Record7

Record6

Part 2

Record11

Part 1

Page 27: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 27

Design and Specifying Files Physical file

A grouping of all occurrences of a given record structure

Often referred to as a table

Page 28: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 28

Table 10-5. Common File Types and Uses

Page 29: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 29

File Access methods Sequential File Access

A record is accessed by scanning the file from the beginning until the desired record is found

Direct or Random Access The address of the block containing

the record is determined and then that block is retrieved

Page 30: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 30

File Organization Sequential file

Files are organized in ascending order according to the primary key

A lookup table is often organized using this method

Figure 10-8

Page 31: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 31

File Organization Index file

An index is created that allows the database application to locate a record

The record can be stored in either sequential or random manner

Figure 10-9

Page 32: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 32

File Organization Direct file

Allows a record to be retrieved using a single disk access operation

Maximizing retrieval speed is the primary objective

Figure 10-10

Page 33: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 33

Figure 10-8. Sequential File Organization Method

Record 1 Record 2 Record 3 Record 4 Record 5 Record 6 …432751 472982 475631 599874 763216 76327 …

Physical Record Position in File

Record Primary Key

Page 34: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 34

Figure 10-9. Example of Record Lookup Using an Indexed File Organization Approach

1500

2501

3317

500

1000

1500

1800

2200

2501

2873

3161

3317

127

275

500

583

729

1000

1179

1320

1500

661

703

717

719

722

723

726

727

729

Master Index

Cylinder Index

Track Index

Track 2

Track 1

Track 3

Page 35: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 35

Figure 10-10. Division-Remainder Hashing Algorithm

The general computation for determining a relative storage address slot for a particular record is:

Relative slot address = 1 + Remainder of Primary Key Value _ Total Number of Reserved Address

Assume a PRODUCT file with 4, 500 unique records. The storage allocation for this file is equal to the number of records, therefore 4,500 storage slots will be needed on the media.

The primary key for records in this file is the PRODUCT_ID field.

The location for PRODUCT_ID 734171 can be computed as follows:

Relative slot address = 1 + Remainder of 734171 _ = 1 + 671 = 672 4500

Page 36: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 36

File Volumetrics Analysts must determine the

desired storage space for a given file in the database.

The concept of volumetrics is intended to address the question of exactly how much data is needed.

Page 37: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 37

File Volumetrics The size of a file is dependent on:

Field data type Record structure Storage media employed Block size File organization scheme

Page 38: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 38

Table 10-6. Example of Volumetric Analysis for INVOICE File

Page 39: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 39

Designing the Database Database is a coherent and

concise source of data for a variety of users and a variety of applications

Database management system is the central nervous system of a database

Page 40: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 40

Database Architecture Network Hierarchical Relational Object-oriented

Page 41: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 41

Network Database Model One of the earliest database

architectures Each file in the database may be

associated with any number of subordinate or superior files

Page 42: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 42

Figure 10-11. Example of a Network Database Architecture

Page 43: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 43

Hierarchical Database Model Links the files in the database in

the form of a hierarchy A parent file can have many

children, but a child file can have only one parent

Page 44: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 44

Figure 10-12. Example of Hierarchical Database Architecture

STUDENTFILE

STUDENTFILE

ACADEMIC ACTIVITYFILE

ACADEMIC ACTIVITYFILE

FINANCIAL ACTIVITYFILE

FINANCIAL ACTIVITYFILE

CURRENT COURSEFILE

CURRENT COURSEFILE

Page 45: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 45

Relational Database Model Can be visualized as a set of two-

dimensional tables or spreadsheets made up of column and rows

Files are linked together by relations formed via attributes shared by two files

Page 46: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 46

Figure 10-13. Example of a Relational Database Architecture

Field 1 Field 2 Field 3 Field 4 Field 5 Field 6Record 1Record 2Record 3Record 4Record 5Record 6Record 7Record 8

RELATION A (Primary Key, Attribute 1, Attribute 2, Attribute 3, …)

RELATION B (Primary Key, Foreign Key, Attribute 2, Attribute 3, …)

Page 47: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 47

Object-Oriented Database Model Encapsulates both the attributes

associated with an object and the methods that operate on those objects in a structure referred to as an object class

Relationship between object classes are shown by nesting one object class inside another

- End -

Page 48: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

SAD/CHAPTER 10 48

Chapter Summary The effective design of the physical

database is a key element in the successful design and implementation of an organizational IS.

The skill of designing and implementing the relational database model will remain viable for many years to come.

Page 49: Chapter 10 Designing the Files and Databases. SAD/CHAPTER 102 Learning Objectives Discuss the conversion from a logical data model to a physical database

Chapter 10

End of Chapter