510 likes | 962 Vues
Physical Database Design Chapter 5. Agenda. Purpose Activities Fields Records Files. Purpose. Determine physical specifications for data Goal: Processing Efficiency Performance Integrity Security Recoverability. Physical Design Activities. Choose DBMS Detailed definitions for:
E N D
Physical Database DesignChapter 5 G. Green
Agenda • Purpose • Activities • Fields • Records • Files
Purpose • Determine physical specifications for data • Goal: Processing Efficiency • Performance • Integrity • Security • Recoverability
Physical Design Activities • Choose DBMS • Detailed definitions for: • fields (data dictionary) • records (physical record structure, quantity ) • files (access methods, space requirements) • Physical File Creation • Query Optimization
Physical Design Activities • Choose DBMS • Detailed definitions for: • fields (data dictionary) • records (physical record structure) • files (access methods)
Choosing a DBMS NOTE: This diagram is for effect ONLY—it is incomplete (e.g., no MDDB, no ODDB) AND contains some inaccuracies
Choosing a DBMS, cont… • Compatibility with existing hardware, software, network, operating system • DBMS features meet requirements* • Needed functionality • Structure of data • Nature of Workload • Product reliability • Vendor support • IT personnel expertise • Pricing, licensing
Physical Design Activities • Choose DBMS • Detailed definitions for: • fields (data dictionary) • records (physical record structure) • files (access methods)
Designing Fields • Choose data types and lengths • Represent all possible values • Ensure data integrity • Support data manipulations • Minimize storage space • Additional data integrity controls: • defaults • ranges • nulls • referential integrity • Document above in data dictionary • see Table 1-1 • see Table 4-1
Designing Fields, cont… • Text • Char vs. Varchar • Numbers • Int vs. Decimal (or Numeric) • Dates • Date vs. Time vs. Datetime • Others (will not use in class)
Physical Design Activities • Choose DBMS • Detailed definitions for: • fields (data dictionary) • records (physical record structure) • files (access methods)
Designing Records • Understand data usage • Re-design records for efficiency?
Designing Records, cont... • Re-design options include: • Denormalization • What? • When? • Why? • Why not? • Partitioning • Horizontal (row) • Vertical (column)
A possible denormalization situation: a many-to-many relationship with nonkey attributes Original entities: Extra table access required Duplicate descriptions possible
Physical Design Activities • Choose DBMS • Detailed definitions for: • fields (data dictionary) • records (physical record structure) • files (access methods)
Designing Files • Efficient access to data • File Organizations • sequential • indexed • hashed • Efficient storage of data • How much storage?
Sequential File Organization • Records physically ordered • often by PK • Examples • Advantages • Disadvantages
Indexed File Organization • Data Records physically ordered • Index Records give physical location of each data record • indexes are separate files • Example • Why? • Why not?
Indexed File Organization, cont... Without Index: PRODUCTTable • 10,000 records • Record size =.5Kb • Page size = 1Kb • 20% = type E • “Find all products • of type E” • How many I/Os?
Indexed File Organization, cont... With Index: PROD_TYPE Index PRODUCTTable • 10,000 records • Record size =.5Kb • Page size = 1Kb • 20% = type E • 1 byte for TYPE • 4 bytes for ADDR • “Find all products • of type E” • How many I/Os?
Indexed File Organization, cont... • Types of Indexes • Primary Key Index • Secondary (Key) Indexes • Clustered Index • How to structure indexes? • B-Tree • Bitmap • …
B-Tree Index Organization Root Branch rowid rowid rowid rowid rowid rowid rowid rowid rowid Leaf See http://www.ovaistariq.net/733/understanding-btree-indexes-and-how-they-impact-performance/ for more information
Summary • Purpose • Activities • Choose DBMS • Fields • Data dictionary • Data types • Records • Usage • Denormalization • Files • Organizations • Indexing
Next Time… • 2/20 Assignment 3: Logical DB Des **DUE** • 2/25 Intro to SQL Server & SQL DDL, DML • Chapters 6 & 7 (see schedule for pages) • 2/27 ** EXAM 1 ** • 3/6 Team Project 1 **DUE **