Kĩ thuật lập trình - Chapter 10: Data management layer design
Sequential access files allow sequential operations
Read, write, and search
Efficient for report writing
Searches are not efficient because an average of 50% of records have to be accessed
Two versions
Ordered
unordered
33 trang |
Chia sẻ: huyhoang44 | Lượt xem: 892 | Lượt tải: 0
Bạn đang xem trước 20 trang tài liệu Kĩ thuật lập trình - Chapter 10: Data management layer design, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Chapter 10:Data Management Layer DesignObjectivesBecome familiar with several object-persistence formats.Be able to map problem domain objects to different object-persistence formats.Be able to apply the steps of normalization to a relational database.Be able to optimize a relational database for object storage and access.Become familiar with indexes for relational databases.Be able to estimate the size of a relational database.Be able to design the data access and manipulation classes.The Data Management LayerIncludes both data access and manipulation logic, andthe actual design of the storageFour-step design approachSelecting the format of the storageMapping problem-domain objects to object-persistence formatoptimizing the object-persistence formatdesigning the data access & manipulation classesOBJECT PERSISTENCE FORMATSObject Persistence FormatsFiles (Sequential and Random)Relational databasesObject-relational databases Object-oriented databasesSample FileFictitious customer databaseSequential & Random Access FilesSequential access files allow sequential operationsRead, write, and searchEfficient for report writingSearches are not efficient because an average of 50% of records have to be accessedTwo versionsOrderedunorderedRandom Access FilesAllow only random or direct file operationsGood for finding and updating a specific objectInefficient report writingApplication File TypesMaster FilesLook-up filesTransaction filesAudit fileHistory fileRelational DatabasesCollection of tablesComprised of fields that define entitiesPrimary key has unique values in each row of a tableForeign key is primary key of another tableTables related to each otherPrimary key field of a table is a field of another table and called a foreign keyRelationship established by a foreign key of one table connecting to the primary key of another tableDatabase Management SystemSoftware that creates and manipulates a databaseRDBMS is a DBMS for a relational databaseRDBMS usually support Referential Integritythe idea of ensuring that values linking the tables together through the primary and foreign keys are valid and correctly synchronizedReferential Integrity ExampleThe class Customer has an attribute custIDThe class Order has an attribute custID that indicates the customer who placed the orderYou should not be able to create an order for a non-existing customerdelete a customer who has placed orders, unless there is a policy on what to do with those orderschange the custID value of a customer, unless you also change the values of his or her ordersThe Structured Query LanguageStandard language for accessing data in tablesSQL CommandsCreate, edit, and delete tablesAdd, edit, and delete dataDisplay data from one or more related tablesDisplay data computed from data in one or more related tablesSELECT * FROM customers WHERE custID=77Selecting Persistence FormatsMAPPING PROBLEM-DOMAIN OBJECTS TO OBJECT-PERSISTENCE FORMATSMapping PD Classes to RDBMSMap all concrete problem domain classes to the RDBMS tables. Map single valued attributes to columns of the tables.Map methods to stored procedures or to program modules.Map single-valued aggregation and association relationships to a column that can store the key of the related tableMap multi-valued attributes and repeating groups to new tables and create a one-to-many association from the original table to the new ones.Mapping PD Classes to RDBMSMap multi-valued aggregation and association relationships to a new associative table that relates the two original tables together. Copy the primary key from both original tables to the new associative tableFor aggregation and association relationships of mixed type, copy the primary key from the single-valued side (1..1 or 0..1) of the relationship to a new column in the table on the multi-valued side (1..* or 0..*) of the relationship that can store the key of the related tableEnsure that the primary key of the subclass instance is the same as the primary key of the superclass..OPTIMIZING RDBMS-BASED OBJECT STORAGEOptimizing Storage EfficiencyNo redundant dataWastes spaceAllows more room for errorFew null values in tablesDifficult to interpretNormalizationTells us how well-formed data is in an RDBMSReduces data redundanciesFirst four levels of normalization are0 Normal Form: normalization rules not applied1 Normal Form: no multi-valued fields2 Normal Form: depend on a whole primary keys3 Normal Form: no fields depend on non-primary key fieldsSteps of NormalizationOptimizing Storage Example – 0NFOptimizing Storage Example – 1NF1NF Sample RecordsOptimizing Storage Example – 2NF2NF Sample RecordsOptimizing Storage Example – 3NFNONFUNCTIONAL REQUIREMENTS AND DATA MANAGEMENT LAYER DESIGNNon-Functional RequirementsOperational RequirementsDAM layer technologies that must be usedPerformance RequirementsDAM layer speed and capacitySecurity RequirementsAccess controls, encryption, and backupPolitical & Cultural RequirementsDate formats, currency conversionsDESIGNING DATA ACCESS AND MANIPULATION CLASSESData Access & ManipulationData access & manipulation (DAM) classes act as a translator between the object-persistence and the problem domain objectsThere should be one DAM class for each concrete problem domain classExample DAM Classes SummaryObject Persistence FormatsMapping Problem-Domain Objects to Object-Persistence FormatsOptimizing RDBMS-Based Object StorageNonfunctional Requirements and Data Management Layer DesignDesigning Data Access and Manipulation Classes
Các file đính kèm theo tài liệu này:
- ch10_2712.ppt