50
 Concepts for Object-Oriented Databases

OO Database concepts

  • Upload
    sinisn

  • View
    16

  • Download
    0

Embed Size (px)

DESCRIPTION

OO Database concepts

Citation preview

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 1/50

Concepts for

Object-OrientedDatabases

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 2/50

Introduction

•  Traditional Data Models : Hierarchical, Network (sincemid-!"s#, $elational (since %&'! and commerciallsince %&)*#

• Object Oriented (OO# Data Models since mid-&!"s

• $easons for creation of Object Oriented Databases – Need for more comple+ applications – Need for additional data modelin featres – .ncreased se of object-oriented prorammin lanaes

• Commercial OO Database prodcts / se0eral in the%&&!"s, bt did not make mch impact on mainstreamdata manaement

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 3/50

History of OO Models andSystems

• 1anaes: 2imla (%&!"s#, 2malltalk (%&'!"s#,C33 (late %&)!"s#, 4a0a (%&&!"s#

• Commercial OO Database prodcts: – Ontos of Ontos,

 – 5emstone of 5em2tone 2stems,

 – Objecti0it of Objecti0it .nc6

 – 7ersant of 7ersant Object Technolo,

 – Object2tore of Object Desin,

 – 8$D9NT of 8$D9NT 2oftware,

 – O9T of O9T 2oftware6

 –;;

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 4/50

Overview of Object-Oriented Concepts(1)

• MI! C"IM: – OO databases tr to maintain a direct

correspondence between real-world anddatabase objects so that objects do not losetheir interit and identit and can easil be

identi<ed and operated pon6

• Object: Two components: state (0ale#and beha0ior (operations#6 – 2imilar to proram 0ariable in prorammin

lanae, e+cept that it will tpicall ha0e acomple+ data strctre as well as speci<coperations de<ned b the prorammer

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 5/50

Overview of Object-OrientedConcepts (#)

•  .n OO databases, objects ma ha0e anobject strctre of arbitrar comple+it inorder to contain all of the necessar

information that describes the object6•  .n contrast, in traditional database

sstems, information abot a comple+object is often scattered o0er man

relations or records, leadin to loss of directcorrespondence between a real-worldobject and its database representation6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 6/50

Overview of Object-OrientedConcepts ($)

•  The internal strctre of an object inOO1s incldes the speci<cation ofinstance variables% which hold the

0ales that de<ne the internal state of theobject6

• 8n instance 0ariable is similar to theconcept of an attribte, e+cept that

instance 0ariables ma be encapslatedwithin the object and ths are notnecessaril 0isible to e+ternal sers

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 7/50

Overview of Object-Oriented Concepts (&) 

• OO models insist that all operations a sercan appl to an object mst be prede<ned6

 This forces a complete encapslation ofobjects6

•  To encorae encapsulation, an operationis de<ned in two parts:%6 sinatre or interface of the operation, speci<es

the operation name and arments (orparameters#6

*6 method or bod, speci<es the implementation ofthe operation6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 8/50

Overview of Object-OrientedConcepts (')

• Operations can be in0oked b passin amessae to an object, which incldes theoperation name and the parameters6 The

object then e+ectes the method for thatoperation6

•  This encapslation permits modi<cation ofthe internal strctre of an object, as well

as the implementation of its operations,withot the need to distrb the e+ternalprorams that in0oke these operations

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 9/50

Overview of Object-OrientedConcepts ()

• 2ome OO sstems pro0ide capabilities fordealin with mltiple 0ersions of the sameobject (a featre that is essential in desin

and enineerin applications#6 – =or e+ample, an old 0ersion of an object that

represents a tested and 0eri<ed desin sholdbe retained ntil the new 0ersion is tested and

0eri<ed: – 0er crcial in desin and enineerin

applications6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 10/50

Overview of Object-OrientedConcepts ()

• Operation polymorp*ism: .t refers to anoperation"s abilit to be applied todi>erent tpes of objects? in sch a

sitation, an operation name ma refer tose0eral distinct implementations,dependin on the tpe of objects it isapplied to6

•  This featre is also called operationo0erridin

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 11/50

Object Identity% Object Structure%and +ype Constructors (1)

• ,niue Identity: 8n OO database sstempro0ides a ni@e identit to each independentobject stored in the database6 This ni@eidentit is tpicall implemented 0ia a ni@e,

sstem-enerated object identi.er% or OI/

•  The O.D is sed internall to ni@el identifeach object and to create and manaer inter-object references6

•  The main propert re@ired of an O.D is that it beimmutable0 that is, the O.D 0ale of a particlarobject shold not chane6 This preser0es theidentit of the real-world object beinrepresented6

Obj Id i Obj S d

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 12/50

Object Identity% Object Structure% and+ype Constructors (#)

Objects / Aser de<ned comple+ data tpes

8n object has strctre or state (0ariables# and methods(beha0iorBoperations#

8n object is described b for characteristics

 – .denti<er: a sstem-wide ni@e id for an object

 –Name: an object ma also ha0e a ni@e name in D (optional# – 1ifetime: determines if the object is persistent or transient

 –2trctre: Constrction of objects sin tpe constrctors

• Can be represented as a triple (i,c,0#

 – i is an ni@e id

 – c is a tpe constrctor – 0 is the object state

• Constrctors

 –asic tpes: atom, tple and set

 –Collection tpe: list, ba and arra

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 13/50

Object Identity% Object Structure% and +ypeConstructors ($)

• +ype Constructors: .n OO databases, the state(crrent 0ale# of a comple+ object ma be constrctedfrom other objects (or other 0ales# b sin certaintpe constrctors6

•  The three most basic constrctors are atom% tuple%

and set Other commonl sed constrctors incldelist% ba2% and array

•  The atom constrctor is sed to represent all basicatomic 0ales, sch as inteers, real nmbers,character strins, ooleans, and an other basic datatpes that the sstem spports directl6

•  The atom constrctor is sed to represent all basicatomic 0ales, sch as inteers, real nmbers,character strins, ooleans, and an other basic datatpes that the sstem spports directl6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 14/50

Object Identity% Object Structure% and +ype Constructors (&)

• set- set of 0ales of same tpe with dplication

allowed6

9+ :%*E,FG,'),%*E,G'

• ba2 / set with no dplicate items (mltiset#

9+: %*E,FG,'),G'

• list- ordered collection of items of same tpe6

9+: %*E,EFG,G'

• array / similar to list bt with <+ed siIe6

• tuple / collection of elements of abo0e tpes6if cJtple, the state 0 is a tple of the form

Ka%:i%,a*:i*,;;an:in L where a j is an attribte name

and i j is an O.D

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 15/50

Object Identity% ObjectStructure% and +ype

Constructors (')• 34ample 1

e se i%, i*, iE, 6 6 6 to stand for ni@esstem-enerated object identi<ers6

Consider the followin objects:o% J (i%, atom, Hoston"#

o* J (i*, atom, ellaire"#

oE J (iE, atom, 2arland"#o

F

 J (iF

, atom, G#

oG J (iG, atom, $esearch"#

o J (i, atom, %&))-!G-**"#

o' J (i', set, i%, i*, iE#

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 16/50

Object Identity% ObjectStructure% and +ype

Constructors ()• 34ample 1(cont)

o) J (i

), tple, Kdname:i

G, dnmber:i

F, mr:i

&,

locations:i', emploees:i

%!, projects:i

%%L#

o& J (i&, tple, Kmanaer:i%*,manaerstartdate:i

L#

o%!

 J (i%!

, set, i%*

, i%E

, i%F

#

o%% J (

i%%, set

i%G,

i%,

i%'#

o%*

 J (i%*

, tple, Kfname:i%)

, minit:i%&

, lname:i*!

,

ssn:i*%

, 6 6 6, salar:i*

, sper0isor:i*'

, dept:i)L#

6 6 6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 17/50

Object Identity% ObjectStructure% and +ype

Constructors ()34ample 1 (cont)• The <rst si+ objects listed in this e+ample

represent atomic 0ales6 Object se0en is a

set-0aled object that represents the set oflocations for department G? the set refers tothe atomic objects with 0ales Hoston",ellaire", 2arland"6 Object ) is a tple-0aled object that represents department G

itself, and has the attribtes DNAME,DNUMBER, MGR, LOCATIONS, and so on6 

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 18/50

Object Identity% ObjectStructure% and +ype

Constructors (5)34ample #6

 This e+ample illstrates the di>erence betweenthe two de<nitions for comparin object statesfor e@alit6

o% J (i

%, tple, Ka

%:i

F, a

*:i

L#

o* J (i

*, tple, Ka

%:i

G, a

*:i

L#

oE J (i

E, tple, Ka

%:i

F, a

*:i

L#

oF J (iF, atom, %!#

oG J (i

G, atom, %!#

o J (i

, atom, *!#

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 19/50

Object Identity% ObjectStructure% and +ype

Constructors (7)34ample # (cont)6

.n this e+ample, The objects o% and o2 ha0e equal  

states, since their states at the atomic le0el arethe same bt the 0ales are reached throh

distinct objects oF and o56

Howe0er, the states of objects o% and o3 are

identical , e0en thoh the objects themsel0es are

not becase the ha0e distinct O.Ds6 2imilarl,althoh the states of oF and o5 are identical, the

actal objects oF and o5 are e@al bt not identical,

becase the ha0e distinct O.Ds6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 20/50

Object Identity% Object Structure% and +ypeConstructors (18)

9i2ure 1 :epresentation of a /3;:+M3!+ comple4 object as a 2rap*

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 21/50

Object Identity% ObjectStructure% and +ype

Constructors (11)9i2ure # Specifyin2 t*e object types3mployee% date% and /epartment usin2type constructors

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 22/50

3ncapsulation of Operations%

Met*ods% and ;ersistence (1)

3ncapsulation• One of the main characteristics of OO lanaes

and sstems• $elated to the concepts of abstract data types

and information hiding in proramminlanaes

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 23/50

3ncapsulation of Operations%Met*ods% and ;ersistence (#)

Specifyin2 Object <e*avior via Class

Operations6

•  The main idea is to de<ne the be*avior of a

tpe of object based on the operations that canbe e+ternall applied to objects of that tpe6

• .n eneral, the implementation of an operationcan be speci<ed in a general-purpose

 programming language that pro0idesPe+ibilit and power in de<nin the operations6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 24/50

3ncapsulation of Operations%Met*ods% and ;ersistence ($)

Specifyin2 Object <e*avior via ClassOperations (cont)6

• =or database applications, the re@irement

that all objects be completelencapslated is too strinent6

• One wa of rela+in this re@irement is todi0ide the strctre of an object into0isible and hidden attribtes (instance0ariables#6

l i f O i

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 25/50

3ncapsulation of Operations%Met*ods% and ;ersistence (&)

9i2ure $ ddin2 operations to de.nitions of 3mployee and

/epartment

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 26/50

3ncapsulation of Operations%Met*ods% and ;ersistence (')

Specifyin2 Object ;ersistence via!amin2 and :eac*ability6

• !amin2 Mec*anism: 8ssin an object ani@e persistent name throh which it can beretrie0ed b this and other prorams6

• :eac*ability Mec*anism: Make theobject reachable from some persistent

object6• 8n object is said to be reac*able from an object8 if a se@ence of references in the object raphlead from object 8 to object 6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 27/50

3ncapsulation of Operations%Met*ods% and ;ersistence ()

Specifyin2 Object ;ersistence via!amin2 and :eac*ability (cont)6

• .n traditional database models sch as relationalmodel or 99$ model, all objects are assmed tobe persistent6

• .n OO approach, a class declaration speci<es onlthe tpe and operations for a class of objects6 The

ser mst separatel de<ne a persistent object oftpe set (Department2et# or list (Department1ist#whose 0ale is the collection of references to allpersistent D98$TM9NT objects

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 28/50

3ncapsulation of Operations%Met*ods% and ;ersistence ()

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 29/50

+ype and Class Hierarc*ies andIn*eritance (1)

•  Tpe (class# Hierarch• 8 tpe in its simplest form can be de<ned b

i0in it a tpe name and then listin the namesof its 0isible ( public# fnctions

• hen specifin a tpe in this section, we se thefollowin format, which does not specifarments of fnctions, to simplif the discssion:

 TQ9N8M9: fnction, fnction, 6 6 6 , fnction

9+ample:

9$2ON: Name, 8ddress, irthdate, 8e, 22N

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 30/50

+ype and Class Hierarc*ies andIn*eritance (#)

• Subtype6 when the desiner or ser mstcreate a new tpe that is similar bt notidentical to an alread de<ned tpe

• Supertype6 .t inherits all the fnctions ofthe sbtpe

 

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 31/50

+ype and Class Hierarc*ies andIn*eritance ($)

34ample (1)6

9M1OQ99: Name, 8ddress, irthdate, 8e, 22N,2alar, HireDate, 2eniorit

2TAD9NT: Name, 8ddress, irthdate, 8e, 22N,Major, 58

O$:

9M1OQ99 subtype-of 9$2ON: 2alar,HireDate, 2eniorit

2TAD9NT subtype-of 9$2ON: Major, 58 

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 32/50

+ype and Class Hierarc*ies andIn*eritance (&)

34ample (#)6

Consider a tpe that describes objects in planeeometr, which ma be de<ned as follows:

59OM9T$QO49CT: 2hape, 8rea,$eferenceoint

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 33/50

+ype and Class Hierarc*ies andIn*eritance (')

• 34ample (#) (cont)6

Now sppose that we want to de<ne a nmber ofsbtpes for the 59OM9T$QO49CT tpe, as

follows:

$9CT8N519 subtype-of  59OM9T$QO49CT:idth, Heiht

 T$.8N519 subtype-of  59OM9T$QO49CT:2ide%, 2ide*, 8nle

C.$C19 subtype-of  59OM9T$QO49CT: $adis

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 34/50

+ype and Class Hierarc*ies andIn*eritance ()

• 34ample (#) (cont)68n alternati0e wa of declarin these threesbtpes is to specif the 0ale of the 2hapeattribte as a condition that mst be satis<ed for

objects of each sbtpe:

$9CT8N519 subtype-of 59OM9T$QO49CT(2hapeJrectanle"#: idth, Heiht

 T$.8N519 subtype-of  59OM9T$QO49CT(2hapeJtrianle"#: 2ide%, 2ide*, 8nle

C.$C19 subtype-of  59OM9T$QO49CT(2hapeJcircle"#: $adis

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 35/50

+ype and Class Hierarc*ies andIn*eritance ()

• 34tents: .n most OO databases, thecollection of objects in an e+tent has thesame tpe or class6

• Howe0er, since the majorit of OOdatabases spport tpes, we assme thate4tents are collections of objects of thesame tpe for the remainder of thissection6

• ;ersistent Collection: .t holds acollection of objects that is storedpermanentl in the database and hencecan be accessed and shared b mltipleprorams

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 36/50

+ype and Class Hierarc*ies andIn*eritance (5)

• +ransient Collection: .t e+iststemporaril drin the e+ection of aproram bt is not kept when the proram

terminates

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 37/50

Comple4 Objects (1)

• ,nstructured comple4 object6 permits thestorae and retrie0al of lare objects that areneeded b the database application6

•  Tpical e+amples of sch objects are bitmap

images and long text strings (sch asdocments#? the are also known as binarylar2e objects% or <"O<s for short6

•  This has been the standard wa b which

$elational DM2s ha0e dealt with spportincomple+ objects, lea0in the operations on thoseobjects otside the $DM26

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 38/50

Comple4 Objects (#)

• Structured comple4 object6 .t di>ersfrom an nstrctred comple+ object inthat the object"s strctre is de<ned b

repeated application of the tpeconstrctors pro0ided b the OODM26Hence, the object strctre is de<ned andknown to the OODM26 The OODM2 also

de<nes methods or operations on it6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 39/50

•  Two tpes of $eference semantics – ownership semantics

 – reference semantics

• ownership semantics : is-part-of ,

is-component-of 

• reference semantics : is-associated-with

Comple4 Objects ($)

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 40/50

Ot*er Objected-Oriented Concepts(1)

• ;olymorp*ism (Operation Overridin2)6

 This concept allows the same operation name tobe bond to two or more di>erent

implementations of the operation, dependin onthe tpe of objects to which the operation isapplied

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 41/50

Ot*er Objected-OrientedConcepts (#)

• Multiple In*eritance

Mltiple inheritance in a tpe hierarchoccrs when a certain sbtpe T is a

sbtpe of two (or more# tpes and henceinherits the fnctions (attribtes andmethods# of both spertpes6

=or e+ample, we ma create a sbtpe

ENGINEERING_MANAGER that is a sbtpeof both MANAGER and ENGINEER6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 42/50

• Selective In*eritance

.t allows a sbtpe to inherit alimited nmber of fnctions from thespertpe6 Other fnctions are notinherited6

• 9RC9T clase

• =re@entl sed in 8rti<cial.ntellience applications rather thanOO database sstems6

Ot*er Objected-OrientedConcepts (#)

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 43/50

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 44/50

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 45/50

Ot*er Objected-OrientedConcepts ($)

=ersions and Con.2urations• Man database applications that se OO

sstems re@ire the e+istence of se0eral

0ersions of the same object•  There ma be more than two 0ersions of

an object6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 46/50

Ot*er Objected-OrientedConcepts (&)

• Con.2uration: 8 con<ration of thecomple+ object is a collection consistin ofone 0ersion of each modle arraned in

sch a wa that the modle 0ersions in thecon<ration are compatible and toetherform a 0alid 0ersion of the comple+ object6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 47/50

Summary (1)

• Object identity: Objects ha0e ni@eidentities that are independent of theirattribte 0ales6

• Type constructors: Comple+ objectstrctres can be constrcted b recrsi0elapplin a set of basic constrctors, sch astple, set, list, and ba6

• Encapsulation of operations: oth theobject strctre and the operations that can beapplied to objects are inclded in the objectclass de<nitions6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 48/50

Summary (#)

• Persistent and transient objects:oth persistent and transient objectsare handled niforml6 Objects are

made persistent b bein attached toa persistent collection6• Type hierarchies and inheritance:

Object tpes can be speci<ed bsin a tpe hierarch, which allowsthe inheritance of both attribtes andmethods of pre0iosl de<ned tpes6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 49/50

Summary ($)

• Extents: 8ll persistent objects of a particlartpe can be stored in an e+tent6 9+tentscorrespondin to a tpe hierarch ha0esetBsbset constraints enforced on them6

• Support for complex objects: othstrctred and nstrctred comple+ objectscan be stored and maniplated6

• Polymorphism and operation overriding:

Operations and method names can beo0erriden to appl to di>erent object tpeswith di>erent implementations6

7/18/2019 OO Database concepts

http://slidepdf.com/reader/full/oo-database-concepts 50/50

Summary (&)

• ersioning: 2ome OO sstems pro0idespport for maintainin se0eral 0ersions ofthe same object6