Rekayasa Perangkat Lunak 2 (IN043): Pertemuan 8 Data Management Layer Design
Data Management Layer Focus on how to manage data are stored that can be handled by the programs that run the system, including: Data access. Manipulation logic.
Four Processes of Data Management Design Selecting the format of the storage. Mapping the problem-domain objects to the objectpersistence format. Optimizing the object-persistence format. Designing the data access and manipulation classes necessary to handle the communication between the system and the database.
Files, Database, and Database Management System Files are electronic lists of data that have been optimized to perform a particular transaction. A database is a collection of groupings of information, each of which is related to each other in some way (e.g., through common fields). Logical groupings of information could include such categories as customer data, information about an order, product information, and so on. A database management system (DBMS) is software that creates and manipulates these databases.
Type of Files (1) Master files: store core information that is important to the business and, more specifically, to the application, such as order information or customer mailing information. They usually are kept for long periods of time, and new records are appended to the end of the file as new orders or new customers are captured by the system. If changes need to be made to existing records, programs must be written to update the old information. Lookup files: contain static values, such as a list of valid zip codes or the names of cities. Typically, the list is used for validation. Transaction files: hold information that can be used to update a master file. The transaction file can be destroyed after changes are added, or the file may be saved in case the transactions need to be accessed again in the future.
Type of Files (2) Audit files: record before and after images of data as they are altered so that an audit can be performed if the integrity of the data is questioned. History files (or archive files): store past transactions (e.g., old customers, past orders) that are no longer needed by system users. Typically the file is stored off-line; yet it can be accessed on an as-needed basis.
Example of Order File
Example of Relational Database
Four Types of Object-Persistence Formats Files (sequential and random access). Relational databases. Object-relational databases. Object-oriented databases.
Sequential and Random Access Files (1) Most object-oriented programming languages support sequential and random access files as part of the language. Sequential access and random access files can be used to support master files, look-up files, transaction files, audit files, and history files. Sequential access files allow only sequential file operations to be performed (e.g., read, write, and search). Sequential access files are very efficient for sequential operations, such as report writing. However, for random operations, such as finding or updating a specific object, they are very inefficient.
Sequential and Random Access Files (2) There are 2 kinds of sequential access and random access files: An unordered sequential access file is basically an electronic list of information stored on disk and organized serially (i.e., the order of the file is the order in which the objects are written to the file). Typically, new objects simply are added to the file s end. Ordered sequential access files are placed into a specific sorted order (e.g., in ascending order by customer number).
Relational Database A relational database is based on collections of tables with each table having a primary key a field or fields whose values are unique for every row of the table. The tables are related to each other by placing the primary key from one table into the related table as a foreign key.
Object Relational Database Object-relational database management systems (ORDBMS) are relational database management systems with extensions to handle the storage of objects in the relational table structure. In pure RDBMSs, attributes are limited to simple or atomic data types, such as integers, floats, or chars. However, an attribute in a table could have a data type of map, which would support storing a map. This is an example of a complex data type.
Object-Oriented Database (1) With an object-oriented database management systems (OODBMS), collections of objects are associated with an extent. An extent is simply the set of instances associated with a particular class (i.e., it is the equivalent of a table in a RDBMS). Each instance of a class has a unique identifier assigned to it by the OODBMS: the Object ID. OODBMSs provide support for some form of inheritance, and the idea of repeating groups(fields) or multi-valued attributes. Object Data Management Group (ODMG) has completed the standardization process for defining (Object Definition Language, ODL), manipulating (Object Manipulating Language, OML), and querying (Object Query Language, OQL) objects in an OODBMS.
Object-Oriented Database (2) OODBMSs have mainly been used to support: Multimedia applications or systems that involve complex data (e.g., graphics, video, sound). Application areas, such as computer-aided design and manufacturing (CAD/CAM), financial services, geographic information systems, health care, telecommunications, and transportation. Electronic commerce, online catalogs, and large Web multimedia applications. Examples of pure OODBMSs include Gemstone, Jasmine, O2, Objectivity, Object-Store, POET, and Versant.
Selecting an Object-Persistence Format Each of the file and database storage formats has its strengths and weaknesses, and no one format is inherently better than the others are.
Mapping Problem-Domain Objects to an RDBMS Format (1)
Mapping Problem-Domain Objects to an RDBMS Format (2)
Mapping Problem-Domain Objects to an ORDBMS Format (1)
Mapping Problem- Domain Objects to an ORDBMS Format (2)
Mapping Problem-Domain Objects to an OODBMS Format (1) Rule 1a: OR Add a column(s) to the OODBMS class(es) that represents the subclass(es) that will contain an Object ID of the instance stored in the OODBMS class that represents the additional superclass(es). This is similar in concept to a foreign key in an RDBMS. The multiplicity of this new association from the subclass to the superclass should be 1..1. Add a column(s) to the OODBMS class(es) that represents the superclass(es) that will contain an Object ID of the instance stored in the OODBMS class that represents the subclass(es). If the superclasses are concrete, that is, they can be instantiated themselves, then the multiplicity from the superclass to the subclass is 0..*, otherwise, it is 1..1. Furthermore, an exclusive-or (XOR) constraint must be added between the associations. Do this for each additional superclass. Rule 1b: Flatten the inheritance hierarchy of the OODBMS classes by copying the attributes and methods of the additional OODBMS superclass(es) down to all of the OODBMS subclasses and remove the additional superclass from the design.
Mapping Problem- Domain Objects to an OODBMS Format (2)
Optimizing RDBMS- Based Object Storage
The Steps of Normalization
1 st Normal Form: Remove Repeating Fields (1)
1 st Normal Form: Remove Repeating Fields (2)
2 nd Normal Form: Remove Partial Dependencies (1)
2 nd Normal Form: Remove Partial Dependencies (2)
3 rd Normal Form
Denormalization (1) Denormalization reduces the number of joins that need to be performed in a query, thus speeding up access.
Denormalization (2)
Managing Problem- Domain Objects to RDBMS
Managing Problem- Domain Objects to ORDBMS
Example: Internet Sales System (1)
Example: Internet Sales System (2)
Example: Internet Sales System (3)
Example: Internet Sales System (4)
Exercise Build data management layer according to your group cases.