1 / 36

Agenda – 04/18/2006 and 04/20/2006

Understand the process of translating a logical data description into technical specifications for storing and retrieving data. Learn the goals and tasks involved in physical database design and explore considerations for optimizing database performance.

swhiteside
Télécharger la présentation

Agenda – 04/18/2006 and 04/20/2006

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Agenda – 04/18/2006 and 04/20/2006 • Identify tasks in physical database design. • Define the design goals for physical database design. • Discuss relevant tasks in physical database design. • Discuss considerations for database performance.

  2. What is physical database design? • The process of translating a logical description of data into technical specifications for storing and retrieving data. • Preparing documentation for actual implementation of tables in a database.

  3. Physical vs. logical design • A physical design can look exactly like a logical design. • Small database: Logical design usually is the same as physical design. • Or a physical design can look different than a logical design. • Large database: Physical design will probably change entity structure to ensure good performance. • Differences between physical and logical design stem from: • Goals. • Constraints.

  4. Design goals for physical database design • Provide adequate performance. • Ensure database integrity. • Provide database security. • Anticipate recoverability.

  5. Tasks in physical design • Convert entities into tables. • Identify all necessary data attributes. • Determine correct size and data type for each data attribute. • Choose an appropriate primary key. • Identify foreign keys necessary to sustain relationships. • Define necessary constraints. • Enhance performance. • Identify size and access methods of data. • Choose appropriate hardware. • Create indices. • De-normalize the design as necessary. • Create design and procedures for archiving data.

  6. Questions to answer during physical design for the sample database • How should the super-type of EMPLOYEE be related to the required sub-types? Separate tables or the same table? • How do you relate a sub-type of a generalization relationship (FACULTY) with a weak entity (COURSE OFFERING)? • How will the supertype of COURSE be related to the potential sub-types of the course? Separate tables or the same table? • What should you do with the concatenated key in COURSE OFFERING?

  7. Choosing datatypes for attributes • A datatype is a name or label for a set of values and some operations which one can perform on that set of values. • Examples in SQL: varchar, date, number, integer • Concept of “strongly data typed.” • Objectives for choosing an appropriate data type: • Minimize storage space. • Represent all possible values. • Improve data integrity. • Support all data manipulations.

  8. Choosing an appropriate primary key • General rules: • Must be a unique value for each row in the table. • Cannot be null. • Should be static over the life of the row. • Physical primary key design heuristics: • Should be a single attribute. • Should be numeric. • Should not be “intelligent.” • Should be able to be an “enterprise key.”

  9. Overview of Database Performance • Key metrics for database performance • Minimize response time to access data in a database. • Minimize response time to change contents in a database. • Most concerned with balancing disk access and memory capacity.

  10. Input data relevant to performance • Table profile • Number of tables • Number of rows in a table • Number of attributes in a table • Application profile • Number of screens • Number of reports • Frequency of screen/reports • Number of intended joins • Types of queries • Expected response time

  11. Improving performance • With optimizing use of existing resources. • With better or more resources. • With indexes. • With denormalization. • With procedures to archive data.

  12. Cluster files to better use memory and disk access time

  13. CREATE CLUSTER ordering (CLUSTERKEY CHAR(6)) CREATE TABLE tbl_customer (customer_id CHAR(6) NOT NULL, Address VARCHARs(25)) CLUSTER ordering (customer_id); CREATE TABLE tbl_order (order_id CHAR(6) NOT NULL, Customer_id CHAR(6) NOT NULL, Order_date date) CLUSTER ordering (customer_id);

  14. Add or change resources to improve performance. • Will help a little: more processor power. • Will help more: more memory. • Will really help: Faster, more efficient disk. • RAID: Redundant arrays of inexpensive (or independent) disks. • A set of multiple physical disk drives that appear to the designer and user as a single storage unit. • Segments of data, called stripes, cut across all of the disk drives. • Access can occur concurrently. • www.acnc.com/04_01_00.html • www.raidweb.com/whatis.html • Different types of RAID are available. RAID-0 through RAID-7, RAID-10, 53, 0+1.

  15. RAID Example

  16. Improving performance with indexes • Indexes are probably the single most important tool for improving the performance of a database. • Can add an index to a database with a simple SQL command: • Create index index_name on table (column_name); • Understanding what happens when an index is created requires a basic understanding of indexing and file organization.

  17. File organization and access concepts • File organization. • The physical arrangement of data in a file into records and pages on secondary storage. • File organization dictates the physical placement of records. • File access methods. • The steps involved in retrieving records from a file. • File access methods dictate how data can be retrieved from secondary storage. Options include: • Sequential access from beginning. Sequential access from pre-defined point. • Backwards from end. Backwards from pre-defined point. • Direct. (not really direct – has to go through a series of indices)

  18. General file organization options • Sequential file organization. Records are stored one after another. Referred to as a “heap” or “pile.” • Indexed file organization. Records are stored either ordered or not as in sequential organization. Additional structure, index, is built based on pre-determined keys for the records.

  19. What is an index? • An additional physical file. • An index is a sorted list of pointers stored along with the actual data. • Benefit: Indexes provide faster direct data access. • Drawbacks: • Indexes create slower data updates. • Indexes require periodic reorganization.

  20. What types of indices are used? • Indexes are frequently stored in a structure called a B+-tree. • Other types of indices are: • Bitmap index. Identifies the value of a given column in a given row as being “true/on” or “false/off”. • Join index. Creates an index for multiple tables that are commonly joined together for pre-defined queries.

  21. Clustered vs. non-clustered indices • Clustered index. • Declaration means actual table data will be ordered by the clustered index. • Can only have one clustered index per table. • Greatly improves access time for tables frequently accessed by clustered index. • Decreases update performance if data is volatile. • Not available on all DBMS’s. • Non-clustered index. • Usually the default indexing structure. • Does not change the order of the table data. • Functions as a “secondary” index.

  22. Rules of thumb for applying indexes • Use on larger tables. • Use when a relatively small percentage of the table will be accessed. • Index the primary key of each table. • Index frequently used search attributes. • Index attributes in SQL “ORDER BY” and “GROUP BY” commands. • Use indexes heavily for non-volatile databases; limit the use of indexes for volatile databases. • Avoid indexing attributes that consist of long character strings.

  23. Issues in indexing • Indexes affect table maintenance performance. • Each time an add or delete is performed, the index must be updated along with the data. • Depending on the size of the database, these index updates can be extremely time-consuming. • Imagine the problems with having an index declared for every attribute. • Solutions: • Remove indexes prior to batch updates. • Recreate indexes after the batch update is finished. • Consider using a batch procedure to create indexes after a table has been updated, and before queries are run.

  24. Improving performance with denormalization • Modify the degree of normalization. • Recognize that joins require much time when used in queries. • More joins = more time. • Combine entities with 1:1 relationship into a single entity. • Combine entities with 1:m relationship into a single entity. Usually done with brief repeating groups.

  25. Example for denormalization • Example: • A patient can have up to 4 insurance companies. • Patient is a strong entity. Insurance company is a strong entity. • Normally, the repeating group of insurance companies would be in a separate intersection entity relating a patient to one or more insurance companies. • Diagram on next page

  26. Insurance example - Denormalized

  27. Issues in denormalization • Can be risky. • Introduces potential for data redundancy. • Can result in data anomalies. • Should be documented. • This documentation must be maintained as an “audit path” to the actual implementation of the database. • Logical data model details fully normalized database with an ERD. • Physical data model will show denormalized database with an ERD. • Include in the documentation the reasons for denormalization.

  28. Improving performance with derived data • Derived or calculated data is usually not included in a database. • Not ever included on a logical data model. • Examples of derived data include: extended price, total amount, total pay, etc. • Problems with including derived data in a database: • What happens when the underlying data is changed? How do you ensure that the derived data will also be changed? • For example, let’s say that the total of an order is kept in the database. What happens when an item quantity changes, or an item price changes? The order total, if stored, must also be changed to reflect those changes in the underlying data.

  29. When to include derived data • Sometimes it is a good idea to include derived data in the physical database design: • Use when aggregate values are regularly retrieved. • Use when aggregate values are costly to calculate. • Permit updating only of source data. • Do not put derived rows in same table as table containing source data. • Examples of derived data frequently stored on databases: • Student class standing. • Order and invoice total. • Credit card balance. • Checking account balance.

  30. Organization must manage data resources • Types of data used by an organization: • Current transaction data. • Historical data for decision making. • Audit data for accounting and/or governmental regulations. • Data differentiation: external vs. internal • All must be designed, implemented and maintained. • Must have procedures for extracting, transforming and loading (ETL) data as necessary.

  31. Archive data for audit purposes • Not all data must be stored on a directly accessible data storage device (disk). • Examples of archived data: • Checking transactions. • Tax data. • Accounting audit trail. • Can store data on tape or other cheaper, less accessible media. • Must have procedures for extracting, transforming and loading (ETL) data as necessary. • Archive database design is usually a copy of the transaction database design.

  32. Use a data warehouse • A Data warehouse differs from a transaction database. • Used to support decision making. • Contains aggregated data. • Is frequently denormalized to improve performance. • Contains data in a format specific to answering queries. • Data warehouse is separate from transaction database. • A data warehouse is built from data stored in the transaction database. • Different design. • May use a data warehouse and a transaction database concurrently to answer queries.

More Related