lecture 9 on object oriented database l.
Skip this Video
Loading SlideShow in 5 Seconds..
Lecture 9 on Object-Oriented Database PowerPoint Presentation
Download Presentation
Lecture 9 on Object-Oriented Database

Loading in 2 Seconds...

play fullscreen
1 / 48

Lecture 9 on Object-Oriented Database - PowerPoint PPT Presentation

  • Updated on

Lecture 9 on Object-Oriented Database.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

Lecture 9 on Object-Oriented Database

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. Lecture 9 on Object-Oriented Database To study object-oriented database as a 3rd generation post relational database, its powerful features of inheritance, encapsulation, polymorphism, object identity, stored object identity, class, and method, and object, and above all, how it differentiates with relational database.

    2. Motivations for Object-Oriented Database Systems • - Serious Deficiencies in Current Database Systems • - Promise of Object-Oriented Paradigm for Application Development • - Application Productivity Enhancement • - Offloading of Functions from Applications to Database Systems. e.g. Putting programs inside database (encapsulation).

    3. Evolution of Database Systems - File systems e.g. ISAM, VSAM - Hierarchical Database Systems (e.g. IMS, System 2000) - CODASYL Database Systems (e.g. IDS, Total) - Relational Database Systems (e.g. DB2, ORACLE, SYBASE, INFORMIX). - Extended Relational Database (e.g. UniSQL) - Object-Oriented Database (e.g. GemStone)

    4. Conventional Database Technology: Applications Perspective - Developed for Traditional Business Data Processing - Problematic for Many Non-Traditional Applications, e.g. Multimedia, Engineering, Design, Modeling/Analysis, Geographical, Moledular Biology, Statistical, etc. - Application Developers must do what database systems do not do. e.g. time-consuming and error-prone, potentially repeadted for each application

    5. Conventional Database Technology: Serious Deficiencies - Due to Data Model. e.g. Fixed Data Types (integer, real, string, date, time, money, BLOB). - No Compound Data (complex nested data) - No Procedural Data (programs) - Single Value per Row/Column - Cannot Support Memory Pointer - Chasing Applications (navigate data via memory pointers)

    6. Motivations for Object-Oriented Programming - Software Productivity - Development, Maintenance, and Evolution of Complex Software Systems. - Encapsulation (Data and Program) - Reuse (Inheritance)

    7. Object-Oriented Concepts - Encapsulation - Object = Data + Program - Data = Values of Attributes (Row of a Table) - Program(Method) = Operates on the Data - Value of an Attribute can be an Object as well as a primitive value (number, string)

    8. Example: Object Definition SHAPE attributes: Center-Point Point, Bounding-Box Box, Area Float methods: Display-Shape BOX attributes: X1 Float, Y1 Float, X2 Float, Y2 Float POINT attributes: X Float, Y Float

    9. Example: Stored Representation X Y Center-Point Bounding-Box Area SHAPE object POINT object BOX object Display-Shape X1 Y1 X2 Y2 Display-Shape Code

    10. Reuse - Attributes and Methods Inherited by Other Objects (Display-Shape) SHAPE RECTANGLE (Display-Shape) TRIANGLE (Display-Shape)

    11. Organization of Objects - Organization of Objects - Objects (Instances) Are Grouped into a Class (Table) - Class: Attributes (and Data Types) and Methods

    12. Classes are organized in a class hieraarchy (DAG)- Reuse (Inheritance)SuperclassSubclassSingle vs. Multiple Inheritance - IS-A Relationship Instances of a subclasses are subsumed by (included in) its superclasses SHAPE (superclass) TRIANGLE (subclass) RECTANGLE (subclass)

    13. Object-Oriented Programming and Database Systems - Object-Oriented concepts form a sound basis for Object-Oriented data model. - Object-Oriented data model can remove data model-related definciencies of conventional database systems.

    14. Definition of an Object-Oriented Database System - must support object-oriented data model - must be a database system - not merely persistent storage system for object-oriented programming language (C++, Smalltalk, etc.) - query language, transaction management, access authorization, etc. - each object must have an OID (object identity) with a system generated unique address - each object may have Stored-OID, an OID used as a pointer, referring to another object

    15. - Encapsulation - object = data + program - data = values of attributes - program = methods that operates on the state - value of an object is also a object - Organization of objects - objects are grouped into a class a class has attributes and methods an object may be nested an object has a unique identified - classes are organized in a class hierarchy - Reuse - in a class hierarchy, a subclass inherits attributes and methods from one or more superclasses.

    16. Procedure Data Employee Name Job Salary Hobby WorksFor Attributes Methods Retirement - Benefits Personality - Profile

    17. Complex Nested Objects- Successive refinement of complex data modeling Activity Employee Name NumPlayers Name Job Salary Hobby WorksFor StateCity Company State City Name Location Budget

    18. Multiple inheritance and IS-A Relationship Student Faculty Name Major GPA Home Name Courses Salary Hobby Rank Grad-Student Hours-Worked

    19. Object-Oriented Data Model - Uniform framework for supporting arbitrary data types - Traditional primitive data types - integer, string, boolean, time, date, memory, BLOB - User-defined arbitrary abstract data types - company, employee, memo, etc. - Dynamic addition of new data types - Dynamic composition of new data types from existing data types

    20. Classification and instantiation The objects belonging to a class are collectively described by a class definition. This class structure, encompassing both properties and behaviour, is the natural unit of abstraction in object-oriented systems. Instantiation is the inverse of classification and concerns the generation of distinct objects of a class.

    21. class Hotel attributes name: String; address: String; owner: Company; manager: Set (Person); facilities: Set of string; methods Create (…); ReserveRoom (room#: integer; guest: Person; arrive_date, depart_date: Date Type) end Hotel

    22. Company Instance Hotel Instance Name Trust house Dublin Headquarters Name The Royal Oak Telephone 01-123567 Person Instance Address Bayview Road, Tralee Name John Lee (Company instance) Owner 23 Main, st Address Manager Set (Person instance) DOB 28/8/53 Facilities (swimming_pool, Sauna) Name Mary Kim 1 Market st Address DOB 10/1/56

    23. Examples of Stored_OID pointers

    24. The Role of Inheritance class Vehicle attributes reg_no, make, model: string; colour: Colour Type; mileage: integer; fueltype: (leaded, unleaded, diesel); year: integer; methods New_vehicle (…) end Vehicle

    25. Inheritance represents IS_A relationship class Unlead_Car inherit Car attributes size: (compact, medium, large); extras: set (option Type); method If not leaded_car then call new ( ) on unleaded_car; end Unlead_Car

    26. Constraints are checked for validity following execution of methods of the class class Car inherit Vehicle attributes fueltype: (leader, unleaded);{re-defined} {additional properties of cars} size: (compact, medium, large); extras: set (option Type); constraints if year > 1985 then fueltype = unleaded’ end Car

    27. Trigger specifies a condition and action to be taken when condition met class Inventory_Item; attributes item: Part; qty_in_stock, reorder_level, reqd_level: integer; method add (qty); remove (qty); issue_order (qty); triggers if qty_in_stock < reorder_level then issue_order (reqd_level - qty_in_stock);

    28. Rule of multiple inheritance Name conflicts from inheritance are either managed automatically by the system, or the user can specify a conflict resolution. For example, in UniSQL, the user can specify which name of subclass to inherit Create Class bed_and_breakfast as subclass of accommodations, eatery (rooms set_of (private_room), Owner string) Inherit name of accommodations;

    29. Object-oriented database definition in general Each object belongs to a family, or class, of similar objects. A class is a template (containing code and data) that describes the common characteristics of a set of objects. The object-oriented methodologies simplify database updates and provide faster access to stored data such that programmer simply references the object without writing code to read object from disk into memory.

    30. Polymorphism In object-oriented programming, polymorphism refers to the ability of a single program entity to refer at run-time to instances of a variety of types or classes. A simple form of polymorphism is overloading, which permits the use of the same name for more than one entity in a program, ambiguities being resolved by the system by examination of the context of each occurrence of the name. For example, one may use the name add for operations to add two integers, tow real numbers, or even two character strings. An add operation on variables v1 and v2 is invoked by the call: add (v1, v2) • and the system decides which function to apply by examining the types of v1 and v2.

    31. Example of polymorphism Same function call with different output format: Case 1: • Call Show_all_instance( ) on class full_time_student; Output: Student# Student_name Student_address ……. ……… ………. Case 2: • Call Show_all_instance ( ) on class department; Output: Dept# Dept_name Staff ……… ……… ……

    32. Comparison betweem Relational and OODB 1. Data types and operations: RDB - attributes of normalized relations are non-decomposable simple data types and their operations restricted to retrieving and updating tuples identified by attribute values. OODB - an object-oriented database stores class definitions and instantiations of these classes that need not be simple data types but can refer to other classes, and may even be passed as a parameter to an operator. OODB can define its operation.

    33. 2. Data integrity RDB - incapable of expressing integrity constraints with greater semantics content than straight forward referential integrity. OODB - a class defines a data abstraction including operation specification (methods) applied to instance of class. High degree of data independence can be achieved by defining database in such abstraction. Also an operation on an object can be invoked by a procedure in a class, which can incorporate consistency checks.

    34. 3. Uniqueness RDB - an entity must distinguish it from all other entities. OODB - all objects (class instantiations) have a unique identity. 4. Schema evolution RDB - RDBMS offers very limited for the expansion of existing schema (data structure). OODB - The tight complying between applications and data in the object-oriented models offers considerably more scope for schema evolution through the extension and the effective reuse of application code.

    35. Map EER model & data operation into OODB schema Step 1 Entity  Class: each entity maps into a class. Step 2 Cardinality  Association and inverse association constraints Each cardinality maps into a pair of association attributes Step 3 isa  Inheritance constraints Each isa maps into a superclass object and subclass object inheritance Step 4 Aggregation  “Part Of” data semantics constraint Create aggregation class when component class(es) exist Delete component classes before deleting aggregation class Step 5 Disjoint Generalization  Method When inserting a subclass data, ensure it does not exist in a mutually exclusive subclass

    36. Case Study I: A medical research Group A medical research group maintains a database of all published papers relating to certain kinds of virus. Each paper is published in a particular issue of a journal identified by the name of the journal, the volume number and the number of the issue. A paper may have one or more authors and may be concerned with viruses. The abstract of the paper is recorded, together with the name of each author and the name of the institution at which the research was carried out. Each paper contains references to other papers. Papers published by the research group are stored with contract_no, amount, start_date, finish_date.

    37. Typical operations performed by users of the database are: • Enter a new paper with all its associated information. • List the details of all papers concerning a specified virus. • List the papers of a specified author. • List the papers associated with a specified research contract.

    38. EER model for the Research Institute

    39. The mapped Object-Oriented Schema class Paper Attributes name: string title: string; issue#: integer; year: integer produce_by: Institute inverse is Institute_produce; writen_by: Set (Author) inverse is Author.write; concerns: Set (Virus) inverse is Virus.covered_by; refers_to: Set (Paper); Method Display name, title, issue#, year, produced_by.Institute, written_by.Author, concerns.Virus, refers_to.paper; end Paper

    40. class Internal_Paper inherit Paper attributes associated_contract: Contract inverse is Contract.reports; end Internal_Paper class Virus attributes name, description: string; covered_by: Set (Paper) inverse is Paper.concerns; method Display name, covered_by.paper; end Virus

    41. class Contract attributes contract#, amount: integer; start, end: date; reports: Set (Internal_Paper) inverse is internal_paper.associated_contract; method Display contract#, reports.Internal_Paper; end Contract

    42. class Authorattributes name: string; nationality: NationalityType; date_of_birth: date; write: set (papers) inverse paper.written-by;method Display name, write.papers;end Author class Institute attributes name, address: string; type: InstituteType; produce: set (papers) inverse paper.produce-by; end Institute

    43. Case Study II: map Aggregation into OO Schema

    44. Mapped into OODB Class Section Attributes Section#: integer teach: Course taught-by: instructor Method If Course and Instructor exist then create Section; If deleting Section then delete Course and Instructor; Class Course ::: Class Instructor :::::

    45. Lecture summary Object-oriented database is much powerful than relational database with respect of productivity. However, its features may not be as user friendly as relational database. Therefore, it is not as popular as relational database, and its major applications are limited to multi-media and large software development.

    46. Review Question What are the difference in implementing many-to-many cardinality in Relational schema and in Object-Oriented schema? Which one is more efficient and why? What are the difference in implementing Stored Procedure in Relational database and Method in Object-Oriented database? Which one has more limitation to access database and why?

    47. Tutorial Question An Extended Entity Relationship model has been designed for the database. Show the object-oriented database schema for the implementation of the EER model design of enrollment record.

    48. Reading Assignment Chapter 20 Object and Object-Relational Database of “Fundamentals of Database Systems” Fifth edition by Elmasri & Navathe, Peason, 2007.