Page 3
1. Introduction goupee.vn goupee.com Design of data management layer is four-step process [1] Select format of storage; Alternatives are:- Files (Sequential and Random) Relational databases Object-relational databases Object-oriented databases [2] Map problem domain classes to selected storage format Problem domain objects drive object storage design [3] Optimise storage for efficient performance [4] Design appropriate data access classes and manipulation classes to:- Separate problem domain classes from storage format Handle all communication with the database fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 4
2. Files goupee.vn goupee.com Files contain lists of data, e.g. bytes, characters, strings, integers, records(which contain fields), etc. Usually supported via programming language-dependent operations, e.g. as defined by methods of pre-defined classes FileInputStream, FileOutputStream for byte streams in Java, FileReader and FileWriter classes character streams in Java, RandomAccessFile in Java. Files may be used as masterfiles, look-up files, transaction files, audit files, history files. Sequential access files are accessed by sequential file operations, e.g. read, write, search Such files are very efficient for sequential processing via sequential operations But are very inefficient for random processing, i.e. on average 50% of contents must be accessed to find desired random record fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 5
2.1 Sequential Files goupee.vn goupee.com May be:- Unordered Data is in sequence that it was written to the file, i.e. data is organised serially New data is added to end of file Ordered Data is in sorted order, e.g. ascending order of some component in the data Need to either A) Create a new file for every insertion or deletion OR B) keep in sorted order using pointers which reference the next piece of data in sorted order fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 6
2.2 Random Access Files goupee.vn goupee.com Allow only random or direct file operations Efficient for locating and updating a specific data item Inefficient for report writing as report is usually sequence or subsequence of data in file 2.3 Sequential and random processing Sometimes need both sequential and random processing Can use a sequential file with additional list of keys Key values are data items in which file is to kept in sorted order Actual data is kept in random access file Minimises cost of additions and deletions to sequential file Allows random file to be processed in sequential order Also allows fast random processing via random file alone More effective if both sequential AND random processing to use a database fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 7
2.4 Application File Types goupee.vnMaster Files goupee.com Accumulate data, e.g. data from transaction files Maintained for long time periods and data for new entries is appended to end of file Look-up files Remain unchanged over time, usually used to validate data from elsewhere against stored legal values Transaction files Update masterfiles with transaction information May or may not be disposed of after masterfile has been updated Audit file Contains data relating to changes in other data, e.g. data values before and after each change in those values, the identity and authority of the changer History file Archive of data from another file no longer needed by systems that process the original file fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 8
3. Relational Databases Appear to applications Payment Type goupee.vn as collections of tables is primarygoupee.com Cust ID is primary key key of Payment of Customer table Type table Payment Type is foreign key in Order Order Number is primary key of Order table Order Number is foreign key in Order fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 9
3.1 Referential Integrity goupee.vn goupee.com • Database Management System (DBMS) makes database facilities available to applications • DBMS enforces referential integrity, i.e. ensure values that link tables via primary and foreign keys are valid and synchronised DBMS: Invalid Cust ID valueAttempt to add order: 241 11/23/00 1111 … Order Cust ID Number All Cust ID Values in Order must All Payment Type exist first in values in Order Customer must exist first in Table Payment Type table Tables related through Cust ID fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 10
3.2 Database Management System (DBMS) goupee.vn goupee.com Software that creates and manipulates a database RDBMS is a DBMS for a Relational Database SQL (Structured Query Language) is standard language for creating tables, deleting tables and accessing data in tables SQL Commands act over all rows of tables Create, edit, and delete tables Add, edit, and delete data Display data from one or more related tables Display data computed from data in one or more related tables Queries that include data from >1 table have those tables joined first, based on primary and foreign key relationships, creating one large table Objects need to be converted to be suitable for storage in a table Requires UML class diagram (for object to be stored) to be mapped to relational database schema fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 11
3.3 Object-Relational DBMS’s goupee.vn goupee.com Relational database management systems with extensions that handle object storage in the relational table structure This is usually via user-defined types Example: Create an audio type in DB2 CREATE DISTINCT TYPE AUDIO AS BLOB (1M) Create a new user-defined New types With same representation named (i.e. distinct) type name as the built-in data type BLOB • The type audio is a new (user defined) type that is not comparable to a BLOB (or to any other type). • This inability to compare AUDIO to other types allows functions to be created specifically for AUDIO • It also ensures functions for type AUDIO cannot be applied to other types, i.e. functions for type AUDIO are bound to the AUDIO type fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 12
3.4 Object-Oriented Database Management goupee.vn goupee.com Systems (OODBMS’s) Achieved by either A) Adding persistence extensions to an object-oriented programming language B) Creating a entirely separate database management system The Object Data Management Group (ODMG) is standardising process for defining Object Definition Language(ODL), Object Manipulation Language (OML) and Object Query Language (OQL) In OODBMS “extent” = collection of objects of a given class [1] Each instance of a class has a unique identifier called an Object ID (OID) [2] Referential integrity still important [3] Supports some form of inheritance fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 13
3.4.1 An Example OODBMS: Gemstone for SmallTalkgoupee.vn goupee.com Gemstone (an early OODBMS) extends SmallTalk to support Associative access by queries Physical placement of objects in storage OO structures Typing Multi-user access GemStone supports modelling of complex objects and relationships directly and organizes classes of data items into an inheritance hierarchy. A single entity is modelled as a single object, not as multiple tuples spread amongst several relations Properties of entities can be simple data values or other entities. e.g. address component of an employee object can be a structured object with components for street number, street and city, and its own defined behaviour. fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 14
goupee.vn3.4.1 Continued… goupee.com Employee Employee object Person Name Contains Person Name First Name Object String Emp. Name Chris Surname IS Surname String string (value = „Harrison‟) Harrison Social Security Number SmallInteger WX012345D Street Address Address Street No. Small Integer 1015 Structure of Employee object Street String West Street City String Manchester Salary Small Integer 25,000 fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 15
3.4.1 continued… goupee.vn goupee.com In GemStone, a data object retains its identity but can have its state changed Entities with information in common can be modelled as two objects with a shared subobject containing the common information (reducing "update anomalies" that exist in the relational data model). In the relational model, properties of an entity must be sufficient to distinguish it from all other entities. For one entity to refer to another, there must be some fields that uniquely and immutably identify the other entity. GemStone supports simulation of the behaviour of real-world entities. Data manipulation commands in conventional systems are oriented towards machine representations, e.g. "modify field,“ "insert tuple," "get next within parent." In GemStone, a message can be defined that takes parameter values, and which performs all the necessary checks and updates to the database. Sending one message takes the place of many database operations. empSet Select: {:anEmp | anEmp.empName.lastName = ‘Harrison’}fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 16
goupee.vn4. Main advantages and disadvantages of goupee.com storage formats for objects Files Very efficient for specific suited task Manipulation done via OO programming language Redundant data usually results RDBMS Proven commercial technology (especially for large data sets) Supports several types of data (but only data of simple types and restricted range of such types) No support for object orientation ORDBMS Inherit RDBMS strengths Supports more complex user-defined types Limited support for object-orientation (support is vendor dependent) OODBMS Support all object types (inbuilt and user-defined types) Support object-orientation directly fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 17
4.1 Criteria for Object Persistence Formats goupee.vn goupee.com (Data) types to be supported Types of application systems to be constructed (transaction processing, Decision Support System, …) Existing Storage Formats Future Needs Other miscellaneous criteria (cost, concurrency control, …) fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 18
5. Mapping Objects to Object-Persistence Formats goupee.vnIf OODBMS is to be used: goupee.com Each concrete problem domain class has corresponding object persistence class Each object persistence class has a DAM (Data Access and Management) class that manages interaction between object persistence class and problem domain layer Unchanged from analysis phase Must be able to read from Dependent on New Class and write to the OODBMS New Class fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 19
5.1 Multiple Inheritance goupee.vn goupee.com If multiple inheritance in problem domain but NOT supported by OODBMS Multiple inheritance has to be factored out of OODBMS classes (but remains in problem domain) For each case of multiple inheritance rules are:- Rule 1a. Add an attribute(s) to the OODBMS class to represent the additional superclass Multiplicity of new new association from subclass to “superclass” is 1..1 Add an attribute(es) to OODBMS class(es) that represent the superclass(es) that that will contain an Object ID of the instance stored in the OODBMS class that represents the subclass(es) If superclass(es) are concrete (can be instantiated) then multiplicity from superclass to subclass is 0..* (otherwise 1..1) Add exclusive OR (Xor) constraint between associations Rule 1b. Flatten the inheritance hierarchy By copying attributes of ODBMS superclass(es) down to all of subclass(es) Remove additional superclass(es) from design fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Page 20
Example:- Attribute represents subclass that will contain an Object ID goupee.vn of instance stored in OODBMS class that “represents”goupee.com “additional” superclasses Assume Superclass2 is concrete Add attribute to Add attribute to OODBMS class OODBMS class Add associations between Shown XOR Class2OODBMS and constraint Superclass2OODBMS, XOR Class1OODBMS and Superclass2ODBMS Class 1 Add pair of attributes with correct multiplicities Inherits from To represent association Superclass1 and With Class1ODBMS & SUperclass2 Class2ODBMS By rule 1)b) fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
Affichage des 20 premières pages. Téléchargez le document pour le voir en entier.
Commentaires (0)
Aucun commentaire pour le moment. Soyez le premier !