Presentation is loading. Please wait.

Presentation is loading. Please wait.

Physical Database Design

Similar presentations


Presentation on theme: "Physical Database Design"— Presentation transcript:

1 Physical Database Design

2 Introduction The purpose of physical database design is to translate the logical description of data into the technical specifications for storing and retrieving data. The goal is to create a design for storing data that will provide adequate performance and insure database integrity, security and recoverability.

3 Inputs to Physical Design
Normalized relations. Volume estimates. Attribute definitions. Data usage: entered, retrieved, deleted, updated. Response time requirements. Requirements for security, backup, recovery, retention, integrity. DBMS characteristics.

4 Physical Design Decisions
Specifying attribute data types. Modifying the logical design. Specifying the file organization. Choosing indexes.

5 Composite usage map (Pine Valley Furniture Company)

6 Designing Fields Choosing data type. Coding, compression, encryption.
Controlling data integrity. Default value. Range control. Null value control. Referential integrity.

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

8 Designing Fields Handling missing data.
Substitute an estimate of the missing value. Trigger a report listing missing values. In programs, ignore missing data unless the value is significant.

9 Physical Records Physical Record: A group of fields stored in adjacent memory locations and retrieved together as a unit. Page: The amount of data read or written in one I/O operation. Blocking Factor: The number of physical records per page.

10 Designing Physical Files
Physical File: A file as stored on the disk. Constructs to link two pieces of data: Sequential storage. Pointers. File Organization: How the files are arranged on the disk. Access Method: How the data can be retrieved based on the file organization.

11 Sequential File Organization
Records of the file are stored in sequence by the primary key field values.

12 Indexed File Organizations
Index concept. Indexed-sequential file organization: The records are stored sequentially by primary key values and there is an index built over the primary key field. B-tree index. Bitmap index, Fig. 7-5.

13 A possible denormalization situation: reference data

14 Comparisons of file organizations
(a) Sequential

15 (b)Indexed

16 Hashed File Organization
Hashing Algorithm: Converts a primary key value into a record address. Division-remainder method.

17 (c ) Hashed

18 Optimization Decisions
Denormalization Partitioning Selection of File Organization Clustering Files Placement of Indexes Derived Columns Repeating Groups Across Columns Other

19 RAID with four disks and striping

20 Denormalization One-to-one relationship. Fig. 7-3a.
Many-to-many relationship. Fig. 7-3b. One-to-many relationship. Fig. 7-3c.

21 Partitioning Horizontal Partitioning: Distributing the rows of a table into several separate files. Vertical Partitioning: Distributing the columns of a table into several separate files. The primary key must be repeated in each file.

22 Partitioning Advantages of Partitioning:
Records used together are grouped together. Each partition can be optimized for performance. Security, recovery. Partitions stored on different disks: contention. Take advantage of parallel processing capability. Disadvantages of Partitioning: Slow retrievals across partitions. Complexity.

23 Selection of File Organization
Sequential Indexed Indexed-Sequential Indexed (Non-Sequential) Hashed

24 Clustering Files In some relational DBMSs, related records from different tables can be stored together in the same disk area.

25 Rules for Using Indexes
1. Use on larger tables. 2. Index the primary key of each table. 3. Index search fields. 4. Fields in SQL ORDER BY and GROUP BY commands. 5. When there are >100 values but not when there are <30 values.

26 Rules for Using Indexes
6. DBMS may have limit on number of indexes per table and number of bytes per indexed field(s). 7. Null values will not be referenced from an index. 8. Use indexes heavily for non-volatile databases; limit the use of indexes for volatile databases.

27 Rules for Adding Derived Columns
Use when aggregate values are regularly retrieved. Use when aggregate values are costly to calculate. Permit updating only of source data. Create triggers to cascade changes from source data. Do not put derived rows in same table.

28 Rules for Storing Repeating Groups Across Columns
Consider storing repeating groups across columns rather than down rows when: The repeating group has a fixed number of occurrences, each of which has a different meaning or The entire repeating group is normally accessed and updated as one unit.

29 Other Rules 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 replacing a foreign key with an alternate when the alternate is what you are looking for (to avoid join.)

30 Database Architectures
Fig. 7-6. Hierarchical Network Relational Object-oriented Multidimensional

31 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.)


Download ppt "Physical Database Design"

Similar presentations


Ads by Google