Part 8a Object Oriented DB

  • Upload
    hitesh

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

  • 8/15/2019 Part 8a Object Oriented DB

    1/55

    1

    Object-Oriented Databases

    based on

    Fundamentals of Database Systems

    Elmasri and Navathe

    Minor corrections/modifications made by H. Hakimzadeh, 2005

     Acknowledgement: Fariborz Farahmand

  • 8/15/2019 Part 8a Object Oriented DB

    2/55

    2

    Outline

    n Overview of O-O Concepts

    n O-O Identity, Object Structure and Type

    Constructorsn Encapsulation of Operations, Methods and

    Persistence

    n Type Hierarchies and Inheritance

    n Complex Objectsn Other O-O Concepts

  • 8/15/2019 Part 8a Object Oriented DB

    3/55

    3

    Introduction

    n Reasons for creation of Object

    Oriented Databases

    n Need for more complex applications

    n

    Need for additional data modeling featuresn Increased use of object-oriented programming

    languages

  • 8/15/2019 Part 8a Object Oriented DB

    4/55

    4

    Public Domain and Commercial Systems

    n Research OODB systems: Orion, Open-OODB at T.I.,

    ODE at ATT Bell labs, Postgres - at UCB, etc.

    n Commercial OODB products: Ontos, Gemstone,

    Objectivity, Objectstore, Versant, etc.

    n For more see:n http://www.service-architecture.com/products/object-oriented_databases.html

  • 8/15/2019 Part 8a Object Oriented DB

    5/55

    5

    The Main Claim

    n OO databases try to maintain a direct

    correspondence between real-world and

    database objects so that objects do not losetheir integrity and identity and can easily be

    identified and operated upon

    n OODBs handle complex data types better 

    n OODBs handle complex operations better 

  • 8/15/2019 Part 8a Object Oriented DB

    6/55

  • 8/15/2019 Part 8a Object Oriented DB

    7/55

  • 8/15/2019 Part 8a Object Oriented DB

    8/55

    8

    Instance Variables vs. Attributes

    n The internal structure of an object in OOPLsincludes the specification of instance

    variables, which hold the values that define

    the internal state of the object.

    n Hence, an instance variable is similar to theconcept of an attribute, except that instance

    variables may be encapsulated within theobject and thus are not necessarily visible toexternal users.

  • 8/15/2019 Part 8a Object Oriented DB

    9/55

    9

    Object-Oriented Concept

    n Some OO models insist that all operations auser can apply to an object must bepredefined. This forces a completeencapsulation of objects.

    n To encourage encapsulation, an operation isdefined in two parts:

    n signature or interface of the operation, specifies

    the operation name and arguments (orparameters).

    n method or body, specifies the implementation ofthe operation.

  • 8/15/2019 Part 8a Object Oriented DB

    10/55

    10

    Encapsulation in OODBs

    n Operations can be invoked by passing a message to

    an object, which includes the operation name and the

    parameters.

    n The object then executes the method for that

    operation.

    n Encapsulation permits modification of the internalstructure of an object, as well as the implementation of

    its operations, without the need to disturb the external

    programs that invoke these operations

  • 8/15/2019 Part 8a Object Oriented DB

    11/55

    11

    Versioning…

    n Some OO systems provide capabilities fordealing with multiple versions of the same

    object (a feature that is essential in design and

    engineering applications).

    n For example, an old version of an object thatrepresents a tested and verified design should

    be retained until the new version is tested andverified:

    - very crucial for designs in manufacturing process

    control, architecture, software systems …

  • 8/15/2019 Part 8a Object Oriented DB

    12/55

    12

    Overloading in OODBs

    n Operator polymorphism: It refers to anoperation’s ability to be applied to different

    types of objects; This feature is also called

    operator overloading

  • 8/15/2019 Part 8a Object Oriented DB

    13/55

    13

    Object Identity

    n The OODB provides a unique identity to eachindependent object stored in the database.

    n

    This unique identity is typically implemented via aunique system-generated object identifier, or OID.

    n The main property required of an OID is that it beimmutable; that is, the OID value of a particular

    object should not change over the life of the object.This preserves the identity of the real-world objectbeing represented.

  • 8/15/2019 Part 8a Object Oriented DB

    14/55

  • 8/15/2019 Part 8a Object Oriented DB

    15/55

    15

    Type Constructors

    n The three most basic type constructors (types) areatom, tuple, and set.

    n Other commonly used type constructors include list,bag, and array.

  • 8/15/2019 Part 8a Object Oriented DB

    16/55

    16

    Example of an object

    n The atom constructor is used to represent all basicatomic values, such as integers, real numbers,character strings, booleans, and any other basic datatypes that the system supports directly.

    We use i 1, i 2, i 3, . . . to stand for unique system-generated object identifiers.

    o1 = (i 1, atom, ‘Houston’)

    o2 = (i 4, atom, 5)

    o3 = (i 7, set, {i 1, i 2, i 3})

  • 8/15/2019 Part 8a Object Oriented DB

    17/55

    17

    n Recall the COMPANY schema, visualize the Research

    department and its components using the relational model.

    Research

    Dept

  • 8/15/2019 Part 8a Object Oriented DB

    18/55

    18

    Example 1:

  • 8/15/2019 Part 8a Object Oriented DB

    19/55

    19

    Example 1 (cont.):

  • 8/15/2019 Part 8a Object Oriented DB

    20/55

  • 8/15/2019 Part 8a Object Oriented DB

    21/55

    21

    Now visualize the Research Department

    in Object Oriented Model

  • 8/15/2019 Part 8a Object Oriented DB

    22/55

    22

    Object Identity, Object Structure, and

    Type Constructorsn Example 1

    We use i 1, i 2, i 3, . . . to stand for unique system-generated object identifiers. Consider the followingobjects:

    o1 = (i 1, atom, ‘Houston’)

    o2 = (i 2, atom, ‘Bellaire’)

    o3 = (i 3, atom, ‘Sugarland’)

    o4 = (i 4, atom, 5)o

    5= (i 

    5, atom, ‘Research’)

    o6 = (i 6, atom, ‘1988-05-22’)

    o7

    = (i 7, set, {i 

    1, i 

    2, i 

    3})

  • 8/15/2019 Part 8a Object Oriented DB

    23/55

    23

    Object Identity, Object Structure

    Example 1 (cont.)

    n The first six objects listed in this example

    represent atomic values.

    n Object 7 is a set-valued object that represents theset of locations for department 5; the set refers to

    the atomic objects with values {‘Houston’,

    ‘Bellaire’, ‘Sugarland’}.

  • 8/15/2019 Part 8a Object Oriented DB

    24/55

    24

    Object Identityn Example 1 (cont.)

    o8 = (i 8, tuple, )

    o9 = (i 9, tuple, )

    o10 = (i 10, set, {i 12, i 13, i 14})

    o11

    = (i 11

    , set {i 15

    , i 16

    , i 17

    })

    o12 = (i 12, tuple, )

    . . .

  • 8/15/2019 Part 8a Object Oriented DB

    25/55

    25

    Object Identity, Object Structure

    Example 1 (cont.)

    n Object 8 is a tuple-valued object that represents

    department 5 itself, and has the attributesDNAME, DNUMBER, MGR, LOCATIONS, and so

    on.

  • 8/15/2019 Part 8a Object Oriented DB

    26/55

    26

    Equal vs. Identical Objects

    n Two objects are said to have identical values, if

    the graphs representing their values are identical

    in every respect, including the OIDs at every level.

    n Two object are said to have equal values if their

    graph structure is the same, all the corresponding

    atomic values should also be the same (same

    states at the atomic level) but their OID do nothave to be the same.

    n Equal is a weaker notion.

  • 8/15/2019 Part 8a Object Oriented DB

    27/55

    27

    Equal vs. Identical Objects

    Example 2:

    This example illustrates the differencebetween the two definitions for comparing

    object states for equality.o

    1= (i 

    1, tuple, )

    o2

    = (i 2, tuple, )

    o3

    = (i 3, tuple, )

    o4

    = (i 4, atom, 10)

    o5

    = (i 5, atom, 10)

    o6

    = (i 6, atom, 20)

  • 8/15/2019 Part 8a Object Oriented DB

    28/55

    28

    Equal Object States

    Example 2 (cont.):

    n In this example, The objects o1

    and o2 have

    equal states, since their states at the atomiclevel are the same but the values are reached

    through distinct objects o4 and o5 .

  • 8/15/2019 Part 8a Object Oriented DB

    29/55

    29

    Identical Object States

    Example 2 (cont.):

    n However, the states of objects o1

    and o3 areident ical , even though the objects themselves

    are not because they have distinct OIDs.

    n Similarly, although the states of o4 and o5 are

    identical, the actual objects o4 and o5  are

    equal but not identical, because they havedistinct OIDs.

  • 8/15/2019 Part 8a Object Oriented DB

    30/55

    30

    Graphical Representation of a Complex

    ObjectResearch Department

  • 8/15/2019 Part 8a Object Oriented DB

    31/55

  • 8/15/2019 Part 8a Object Oriented DB

    32/55

    32

    Encapsulation of Operations, Methods, and

    Persistence

    Encapsulation

    n One of the main characteristics of OO languages and systems

    n related to the concepts of abstract data types and information

    hiding in programming languages

  • 8/15/2019 Part 8a Object Oriented DB

    33/55

    33

    Encapsulation of Operations, Methods,

    and Persistence (cont.)

    Specifying Object Behavior via Class Operations:

    n The main idea is to define the behavior of a type of

    object based on the operations that can beexternally applied to objects of that type.

  • 8/15/2019 Part 8a Object Oriented DB

    34/55

    34

    Encapsulation of Operations, Methods,

    and Persistence (cont.)

    Specifying Object Behavior via Class Operations

    (cont.):

    n For database applications, the requirement that all

    objects be completely encapsulated is too stringent.

    n One way of relaxing this requirement is to divide the

    structure of an object into visible and hidden attributes

    (instance variables).

  • 8/15/2019 Part 8a Object Oriented DB

    35/55

  • 8/15/2019 Part 8a Object Oriented DB

    36/55

    36

    11.4 Type Hierarchies and Inheritancen Type (class) Hierarchy

    n  A type in its simplest form can be defined by it’s type

    name and a listing of the names of its visible/ public functions.

    TYPE_NAME: function, function, . . . , function

    Example:

    PERSON: Name, Address, Birthdate, Age, SSN

  • 8/15/2019 Part 8a Object Oriented DB

    37/55

    37

    Type Hierarchies and Inheritance (cont.)

    n Subtype: when the designer or user mustcreate a new type that is similar but notidentical to an already defined type

    n Subtype: inherits all the functions of thepredefined type (also known as thesupertype)

  • 8/15/2019 Part 8a Object Oriented DB

    38/55

  • 8/15/2019 Part 8a Object Oriented DB

    39/55

    39

    Type Hierarchies and Inheritance (cont.)

    Example (2):

    consider a type that describes objects in plane geometry, which

    may be defined as follows:

    GEOMETRY_OBJECT type:

    Shape, Area, ReferencePoint

  • 8/15/2019 Part 8a Object Oriented DB

    40/55

    40

    Type Hierarchies and Inheritance (cont.)

    n Example (2) (cont.):

    Now suppose that we want to define a number of subtypes forthe GEOMETRY_OBJECT type, as follows:

    RECTANGLE subtype-of GEOMETRY_OBJECT:Width, Height

    TRIANGLE subtype-of GEOMETRY_OBJECT:

    Side1, Side2, Angle

    CIRCLE subtype-of GEOMETRY_OBJECT: Radius

  • 8/15/2019 Part 8a Object Oriented DB

    41/55

    41

    Type Hierarchies and Inheritance (cont.)

    n Example (2) (cont.): An alternative way of declaring these three subtypes is tospecify the value of the Shape attribute as a condition that mustbe satisfied for objects of each subtype:

    RECTANGLE subtype-of GEOMETRY_OBJECT(Shape=‘rectangle’): Width, Height

    TRIANGLE subtype-of GEOMETRY_OBJECT(Shape=‘triangle’): Side1, Side2, Angle

    CIRCLE subtype-of GEOMETRY_OBJECT(Shape=‘circle’): Radius

  • 8/15/2019 Part 8a Object Oriented DB

    42/55

    42

    Type Hierarchies and Inheritance (cont.)

    n Extents: collections of objects of the same type.

  • 8/15/2019 Part 8a Object Oriented DB

    43/55

    43

    Type Hierarchies and Inheritance (cont.)

    n Persistent Collection: It holds a collection of objectsthat is stored permanently in the database and hencecan be accessed and shared by multiple programs

  • 8/15/2019 Part 8a Object Oriented DB

    44/55

  • 8/15/2019 Part 8a Object Oriented DB

    45/55

    45

    11.5 Complex Objects

    n Unstructured complex object:

    n Provided by a DBMS

    n Permits the storage and retrieval of large objects that

    are needed by the database application.

    n Examples: of such objects are bi tmap images and

    l ong tex t s t r ings (such as documents); they are also

    known as binary large objects, or BLOBs for short.

  • 8/15/2019 Part 8a Object Oriented DB

    46/55

    46

    Complex Objects (cont.)

    n Structured complex object:

    n Differs from an unstructured complex object in that the

    object’s structure is defined by repeated application of

    the type constructors provided by the OODBMS.

    Hence, the object structure is defined and known to the

    OODBMS.

  • 8/15/2019 Part 8a Object Oriented DB

    47/55

    47

    Other Objected-Oriented Concepts

    n Polymorphism (Operator Overloading):

    This concept allows the same operator name or symbol to be

    bound to two or more different implementations of the operator,

    depending on the type of objects to which the operator is

    applied

  • 8/15/2019 Part 8a Object Oriented DB

    48/55

    48

    11.6 Other Objected-Oriented Concepts

    (cont.)

    n Multiple Inheritance and Selective

    Inheritance

    n Multiple inheritance in a type hierarchy occurs when a

    certain subtype T is a subtype of two (or more) typesand hence inherits the functions (attributes and

    methods) of both supertypes.

    n Example, we may create a subtype

    ENGINEERING_MANAGER that is a subtype of bothMANAGER and ENGINEER. This leads to the

    creation of a type lattice rather than a type hierarchy.

  • 8/15/2019 Part 8a Object Oriented DB

    49/55

    49

    Other Objected-Oriented Concepts

    (cont.)

    Versions and Configurations

    n Many database applications that use OO systems

    require the existence of several versions of the same

    object

    n There may be more than two versions of an object.

  • 8/15/2019 Part 8a Object Oriented DB

    50/55

    50

    Other Objected-Oriented Concepts

    (cont.)

    n Configuration: A configuration of the complex object

    is a collection consisting of one version of each

    module arranged in such a way that the module

    versions in the configuration are compatible and

    together form a valid version of the complex object.

  • 8/15/2019 Part 8a Object Oriented DB

    51/55

    51

    Summary

    n Object ident i ty : Objects have unique identities thatare independent of their attribute values.

    n Type con structors : Complex object structures can

    be constructed by recursively applying a set of basicconstructors, such as tuple, set, list, and bag.

    n Encapsulat ion of operat ions : Both the objectstructure and the operations that can be applied toobjects are included in the object class definitions.

  • 8/15/2019 Part 8a Object Oriented DB

    52/55

    52

    Summary (cont.)

    n Programm ing langu age com patib i l ity : Bothpersistent and transient objects are handleduniformly. Objects are made persistent bybeing attached to a persistent collection.

    n Type hierarch ies and inher i tance : Objecttypes can be specified by using a typehierarchy, which allows the inheritance ofboth attributes and methods of previouslydefined types.

  • 8/15/2019 Part 8a Object Oriented DB

    53/55

    53

    Summary (cont.)

    n Extents : All persistent objects of a particular type canbe stored in an extent. Extents corresponding to atype hierarchy have set/subset constraints enforcedon them.

    n Support for complex objects : Both structured andunstructured complex objects can be stored andmanipulated.

    n Polymo rphism and operator over loading :Operations and method names can be overloaded toapply to different object types with differentimplementations.

  • 8/15/2019 Part 8a Object Oriented DB

    54/55

    54

    Summary (cont.)

    n Versioning : Some OO systems provide support for

    maintaining several versions of the same object.

  • 8/15/2019 Part 8a Object Oriented DB

    55/55

    55

    Current Status

    n OODB market not growing much per se

    n O-O ideas are being used in a large number ofapplications, without explicitly using the OODB

    platform to store data.

    n Growth: O-O tools for modeling and analysis, O-OProgramming Languages like Java and C++

    n Compromise Solution Proposed: Object RelationalDB Management (Informix Universal Server, Oracle9i, IBM’s UDB, …)