20
Object-Oriented Object-Oriented Databases Databases George Klington.A George Klington.A

OODBMS

Embed Size (px)

Citation preview

Page 1: OODBMS

Object-Oriented Object-Oriented

DatabasesDatabases

George Klington.AGeorge Klington.A

Page 2: OODBMS

Object Oriented Object Oriented ConceptsConcepts

ObjectObject An object represents a real world entity (Person), a concept An object represents a real world entity (Person), a concept

(Drama), a logical thing (Licence), a physical thing (Car)(Drama), a logical thing (Licence), a physical thing (Car) Every object has a unique Object Identifier (OID)Every object has a unique Object Identifier (OID) An object is made of two things:An object is made of two things:

State: properties (e.g. State: properties (e.g. name, address, birthDatename, address, birthDate of a of a Person)Person)

Behaviour: operations (e.g. Behaviour: operations (e.g. ageage of a Person is computed of a Person is computed from from birthDatebirthDate and current date) and current date)

Object IdentifierObject Identifier Unique for every objectUnique for every object System generatedSystem generated Never changes in the lifetime of the objectNever changes in the lifetime of the object Not usually visible to the userNot usually visible to the user

Page 3: OODBMS

OO Concepts OO Concepts ClassificationClassification

Classification is the process of grouping together objects which have common Classification is the process of grouping together objects which have common features.features.

Programming languages have type systems and database systems have data Programming languages have type systems and database systems have data models to classify object.models to classify object.

The name used for the classificatory group of values is usually either The name used for the classificatory group of values is usually either classclass or or typetype..

classclass Person Personpropertiesproperties

name: Stringname: Stringaddress: Stringaddress: StringbirthDate: DatebirthDate: Dateoperationsoperations

age(): Integerage(): Integer endend Person Person

Page 4: OODBMS

OO ConceptsOO Concepts EncapsulationEncapsulation

The integration of the description of data structure and The integration of the description of data structure and operation is called operation is called encapsulationencapsulation. .

Objects are composed of properties (values) and Objects are composed of properties (values) and operations.operations.

This feature is missing in Relational Databases (RDBs) and This feature is missing in Relational Databases (RDBs) and is usually coded into the application. is usually coded into the application.

InheritanceInheritance A new class is usually described in terms of one or more A new class is usually described in terms of one or more

previously defined classes from which the new class takes previously defined classes from which the new class takes ((inheritsinherits) properties and operations. For instance, the ) properties and operations. For instance, the following defines a new class following defines a new class StudentStudent:: classclass Student Student ISAISA Person Person

propertiespropertiesmajor: Stringmajor: Stringtutor: Lecturertutor: Lecturer

operationsoperationsregister(C: Course): Booleanregister(C: Course): Boolean

endend Student Student

• Student is sub-type of Person• Person is super-type of Student• A Student is also a Person, but not every Person is a Student.• A Student has all the properties and operations same as Person

Page 5: OODBMS

Why Object Oriented Why Object Oriented databases?databases?

Object Oriented Databases (OODBs) are inevitable Object Oriented Databases (OODBs) are inevitable when:when: Data is complex and variable in sizeData is complex and variable in size Complex structural and compositional relationshipsComplex structural and compositional relationships Data is highly inter-relatedData is highly inter-related Data is evolving rapidly over timeData is evolving rapidly over time Richer data typesRicher data types

complex objectscomplex objects inheritanceinheritance user extensibilityuser extensibility

Behaviour with dataBehaviour with data not just a not just a datadata model but also model but also operations can be bundled together with dataoperations can be bundled together with data

Page 6: OODBMS

OODBMS ManifestoOODBMS Manifesto

Standard OO characteristicsStandard OO characteristics E.g. encapsulation, types, classes, E.g. encapsulation, types, classes,

polymorphism, etc..polymorphism, etc..

DBMS characteristicsDBMS characteristics PersistencePersistence ScalableScalable ConcurrencyConcurrency Fault toleranceFault tolerance Simple query supportSimple query support

Page 7: OODBMS

OO Concepts OO Concepts

An An object systemobject system or or object-based systemobject-based system is one which is one which supports the modeling of data as abstract entities, with supports the modeling of data as abstract entities, with object identity.object identity.

An An object-oriented systemobject-oriented system is an object system in which all is an object system in which all data is created as instances of classes which take part in data is created as instances of classes which take part in an inheritance hierarchy.an inheritance hierarchy.

An An object-oriented database management systemobject-oriented database management system (OODBMS)(OODBMS) is a DBMS with an object-oriented logical data is a DBMS with an object-oriented logical data model.model.

An An object-oriented databaseobject-oriented database is a database made up of is a database made up of objects and managed by an OODBMS.objects and managed by an OODBMS.

Page 8: OODBMS

UML and OO Database UML and OO Database DesignDesign

UML can be used to aid in OO UML can be used to aid in OO Database DesignDatabase Design Use Case DiagramsUse Case Diagrams Class DiagramsClass Diagrams Sequence DiagramsSequence Diagrams State DiagramsState Diagrams

Page 9: OODBMS

Data Storage and AccessData Storage and Access

RDBMSs – two level storage modelRDBMSs – two level storage model Application storage model in main & virtual Application storage model in main & virtual

memorymemory Database storage model on diskDatabase storage model on disk

Secondary Storage

Main Memory

Transformation

Page 10: OODBMS

Data Storage and AccessData Storage and Access

OODBMS uses single level storage OODBMS uses single level storage conceptconcept

Secondary Storage

Main Memory

Page 11: OODBMS

Data Storage and AccessData Storage and Access

Resident Object Table (ROT)Resident Object Table (ROT) Easy implementation, potentially Easy implementation, potentially

inefficientinefficient

Pointer SwizzlingPointer Swizzling More complex, more efficientMore complex, more efficient

Page 12: OODBMS

Object-Relational Database Object-Relational Database SystemsSystems

AdvantagesAdvantages ReuseReuse SharingSharing

DisadvantagesDisadvantages ComplexityComplexity CostsCosts

Page 13: OODBMS

Complex DataComplex Data

Page 14: OODBMS

OODBsOODBs are more Natural & are more Natural & DirectDirect

Page 15: OODBMS

An Example Conceptual An Example Conceptual Schema in ERSchema in ER

Person

Student Lecturer

DepartmentCourseUnit

tutor

N

N 1

enrolledOn

1

offersN 1

worksFor

N

1

partOfN M

takes

d

N

M

teaches

M

N

Student and Lecturer are sub-types Student and Lecturer are sub-types of Person. ‘d’ means that Student of Person. ‘d’ means that Student and Lecturer are disjoint.and Lecturer are disjoint.

A Student cannot be a Lecturer at A Student cannot be a Lecturer at the same time and vice versa.the same time and vice versa.

Attribute names are omitted.Attribute names are omitted.

Page 16: OODBMS

The Conceptual Schema in UMLThe Conceptual Schema in UML

**

Person

name: stringaddress: stringbirthDate: date

age(): integer

Student

major: string

register(C: Course): booleantakeUnit(U: Unit): boolean

Lecturer

room: stringsalary: floatjoinDate: date

teachUnit(U: Unit): bollean

tutor tutees

* 1

Department

deptId: stringname: string

getCourses(): Set(Course)

worksFor staff

* 1

offers 1

deptpartOf units

*

Course

courseCode: stringname: string

getUnits(): Set(Unit)

Unit

unitCode: stringdescription: string

getCourses(): Set(Course)

takes

*takenBy

enrolledOn

*

students

1

*

Page 17: OODBMS

OO RepresentationOO Representation

class Course

properties

name: String

offeredBy: Department

hasStudents: set(Student)

hasUnits: set(Unit)

end Course

class Student ISA Person properties

major: Stringtutor: LecturerenrolledOn: Coursetakes: set(Unit)

operationsregister(C: Course): BooleantakeUnit(U: Unit): Boolean

end Student

class Lecturer ISA Person properties

room: Integertutees: set(Student)worksFor: Departmentteaches: set(Unit)

operationsteachUnit(U: Unit): Boolean

end Lecturer

class Person

properties

name: String

address: String

birthDate: Date

operations

age(): Integer

end Person

class Department

properties

name: String

staff: set(Lecturer)

offers: set(Course)

end Department

class Unit

properties

name: String

code: String

takenBy: set(Student)

taughtBy: set(Lecturer)

partOf: set(Course)

end Unit

Page 18: OODBMS

Advantages of OODB• Greater semantic expressibility: storing and manipulating

complex objects greatly simplifies the model of the application world

• Object identity is superior unifying concept than using surrogates (e.g. primary and foreign keys in relational DBMS)

• The ease of user extensibility

• Behavioural model: programs and data are stored together, unifying conceptually connected features of database

• Typing objects provides a more coherent structure for the database

• Code re-use through inheritance, over-riding and late binding

• A possible pre-requisite to active databases and interoperability?

Page 19: OODBMS

Disadvantages of OODB

• No formal semantics, unlike the relational data model.

• Loss of the relational data model’s simplicity.

• Optimization / tuning(e.g. indexes) not as well understood and are difficult; the overall record-at-a-time flavour of the OO systems means that relational-style optimization is unlikely.

• Transaction management support is not very mature.

• Complexity

• Cost

Page 20: OODBMS

THANK YOU !!!