Object-Oriented Database Systems (part 1) CS263 Lecture 17.

46
Object-Oriented Database Systems (part 1) CS263 Lecture 17
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    218
  • download

    2

Transcript of Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Page 1: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object-Oriented Database Systems (part 1)

CS263 Lecture 17

Page 2: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

LECTURE PLAN

OBJECT DATABASE SYSTEMSPART ONE

Advanced database application areas

Problems associated with RDBMSs

Third Generation DBMSs

What is Object Orientation?

What is an OODBMS?

Page 3: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

ADVANCED APPLICATION AREAS

DATABASES

Computer-Aided Design (CAD).

Computer-Aided Manufacturing (CAM).

Computer-Aided Software Engineering (CASE).

Office Information Systems (OIS).

Multimedia Systems.

Digital Publishing.

Geographic Information Systems (GIS).

Scientific and Medical Systems.

Page 4: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSs

Poor representation of ‘real world’ entities.

Semantic overloading.

Poor support for integrity and business constraints.

Homogeneous data structure.

Limited operations.

Difficulty handling recursive queries.

Impedance mismatch.

Difficulty with ‘Long Transactions’.

PROBLEMS

Page 5: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSs

Poor representation of ‘real world’ entities.

Semantic overloading.

Poor support for integrity and business constraints.

Homogeneous data structure.

Limited operations.

Difficulty handling recursive queries.

Impedance mismatch.

Difficulty with ‘Long Transactions’.

PROBLEMS

Page 6: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSsPROBLEMS - REAL-WORLD OBJECTS

CAR

C#

WHEEL

W#

SEAT

S#

TRIM

T#

C#

W#

C#

HasPart of

Part ofHas

Part of Has

ER Diagram - CarER Diagram - Car

Page 7: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSsPROBLEMS - REAL-WORLD OBJECTS

Select * From Car, Wheel, Trim, SeatWhere Car.C# = Wheel.C# And Car.C# = Seat.C# And Wheel.W# = Trim.W#;

To find out all details about a Car we would have to carry out a large number of (expensive) JOIN operations.

Car {C#, Chassis#, NoWheels, NoSeats, etc…}

Wheel {W#, C#, Size, Pressure, etc…}

Trim {T#, W#, Material, Cost, etc…}

Seat {S#, C#, Material, Size, Cost,, etc…}

NORMALISATION

Page 8: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSs

Poor representation of ‘real world’ entities.

Semantic overloading.

Poor support for integrity and business constraints.

Homogeneous data structure.

Limited operations.

Difficulty handling recursive queries.

Impedance mismatch.

Difficulty with ‘Long Transactions’.

PROBLEMS

Page 9: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSsPROBLEMS - SEMANTIC OVERLOADING

ER DiagramER Diagram

Doctor {D#, Name, Surgery, etc…}

Patient {P#, D#, Name, Address, DOB, etc…}

DOCTOR

D#

PATIENT

P# D#Oversees

Overseen by

DOCTOR

D#

PATIENT

P# D#Kills

Killed by

We do not record the nature of the

relationship between doctor and patient!

Page 10: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSs

Poor representation of ‘real world’ entities.

Semantic overloading.

Poor support for integrity and business constraints.

Homogeneous data structure.

Limited operations.

Difficulty handling recursive queries.

Impedance mismatch.

Difficulty with ‘Long Transactions’.

PROBLEMS

Page 11: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSs

Poor representation of ‘real world’ entities.

Semantic overloading.

Poor support for integrity and business constraints.

Homogeneous data structure.

Limited operations.

Difficulty handling recursive queries.

Impedance mismatch.

Difficulty with ‘Long Transactions’.

PROBLEMS

Page 12: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSsPROBLEMS - HOMOGENEOUS DATA STRUCTURE

333.00STRATFORDKHAN456

500.00BARKINGONO400

340.14BARKINGGREEN350

23.17STRATFORDSMITH345

200.00BARKINGGRAY324

1000.00STRATFORDJONES200

BALANCEBRANCHCUSTOMERACCOUNT

ACCOUNT TABLE

ALL ROWS HAVE THE SAME NUMBER OF ATTRIBUTESALL VALUES IN A COLUMN ARE OF THE SAME TYPEALL ATTRIBUTE VALUES ARE ATOMIC

Page 13: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSs

Poor representation of ‘real world’ entities.

Semantic overloading.

Poor support for integrity and business constraints.

Homogeneous data structure.

Limited operations.

Difficulty handling recursive queries.

Impedance mismatch.

Difficulty with ‘Long Transactions’.

PROBLEMS

Page 14: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSs

Poor representation of ‘real world’ entities.

Semantic overloading.

Poor support for integrity and business constraints.

Homogeneous data structure.

Limited operations.

Difficulty handling recursive queries.

Impedance mismatch.

Difficulty with ‘Long Transactions’.

PROBLEMS

Page 15: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSsPROBLEMS - RECURSIVE QUERIES

Question - Who does SMITH work for?

SMITH

Select E2.ENAME From EMP E1, EMP E2Where E1.MGR = E2.EMPNO And E1.ENAME = “SMITH”;

First Level Answer – SMITH works for FORD

FORD

JONESSelect E3.ENAME From EMP E1, EMP E2, EMP E3Where E1.MGR = E2.EMPNO And E2.MGR = E3.EMPNO And E1.ENAME = “SMITH”;

Second Level Answer - SMITH works for JONES

KING

Select E4.ENAME From EMP E1, EMP E2, EMP E3, EMP E4Where E1.MGR = E2.EMP And E2.MGR = E3.EMPNO And E3.MGR = E4.EMPNO And E1.ENAME = “SMITH”;

Third Level Answer – SMITH works for KING

?

Page 16: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSs

Poor representation of ‘real world’ entities.

Semantic overloading.

Poor support for integrity and business constraints.

Homogeneous data structure.

Limited operations.

Difficulty handling recursive queries.

Impedance mismatch.

Difficulty with ‘Long Transactions’.

PROBLEMS

Page 17: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSsPROBLEMS - IMPEDANCE MISMATCH

SQL is a declarative, set-based language that is not computationally complete!

This is expensive in terms of application processing time and programming effort, accounting for around 30% of some projects!

We therefore have to map sets of data into records using memory structures such as cursors.

Database applications require the use of a computationally complete, record-based, procedural language such as C, C++, Java, and PL/SQL.

Page 18: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

RELATIONAL DBMSs

Poor representation of ‘real world’ entities.

Semantic overloading.

Poor support for integrity and business constraints.

Homogeneous data structure.

Limited operations.

Difficulty handling recursive queries.

Impedance mismatch.

Difficulty with ‘Long Transactions’.

PROBLEMS

Page 19: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

THIRD GENERATION DBMSs

Page 20: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

• Support Complex Active Objects

Allow both data and its associated behaviour to be modelled to any level of complexity.

• Improve Extensibility

Allow for the dynamic extension of both allowable data types and the behaviour associated with these types.

• Reduce the Impedance Mismatch

Ensure that there is a seamless integration between the DBMS data model and that of the programming language accessing the data.

THIRD GENERATION DBMSsMAIN AIMS

Page 21: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

OBJECT ORIENTATION

Page 22: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS AN ATOMIC (LITERAL) OBJECT?

An atomic object is a container for a fixed value and serves the same purpose as a constant in a programming language.

An atomic object cannot change its own state.

Examples of atomic types and atomic objects 

Integer - e.g. 1, 2, 3, -5, -45, etc.....Float - e.g. 1.52, -0.3456, 2.000, etc...Boolean - i.e. True or FalseChar - e.g. a, b, c, @, #, !, etc...String - e.g. “Mark”, “Database Systems”

Page 23: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A (MUTABLE) OBJECT?

I am anobject!

UNIQUE OBJECT IDENTIFIER (OID)

NAME MARKDOB 14/02/1964JOB LECTURER

ATTRIBUTES

State

RELATIONSHIPS

CHANGE JOBGET AGE

BEHAVIOUR

Methods

Page 24: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A CLASS?

I am anobject!

MARK I am alsoan object!

IAN

Page 25: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A CLASS?

MARK I am aPerson! So am I! IAN

PERSON CLASS

PERSONNAMEDOBJOBCHANGE JOBGET AGE

Page 26: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS AN OBJECT IDENTIFIER (OID)?

Each object is uniquely identifiable from all other objects. When an object is first created it is assigned a value to identify it. This value is called its Object Identifier.

System generated. Unique to that object. Invariant in that it cannot be altered. Independent of its attribute values. Invisible to the user.

Page 27: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS ENCAPSULATION?

GE

T A

GE

ME

TH

OD

CH

AN

GE

JOB

ME

TH

OD

NAME: MARKDOB: 14/02/64JOB: LECTURER

GET AGE

CHANGE JOB

OBJECTOBJECT

Page 28: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A COMPLEX OBJECT?

Yes, it’s an object that is made up of other objects!

Wheels, Seats, Chassis, Exhaust, Steering Wheel, etc, etc...

Is a Car a Complex Object?

And… a wheel itself is also a complex object!

Tire, Trim, Hub Cap, etc, etc...

Page 29: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A COMPLEX OBJECT?

CAR

TIRE

HUBCAP

TRIM

TIRE

HUBCAP

TRIM

TIRE

HUBCAP

TRIM

TIRE

HUBCAP

TRIM

CHASSIS

WHEEL

WHEEL WHEEL

WHEEL

SEAT SEAT

SEATSEAT

REGISTRATIONNUMBER

Page 30: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A COMPLEX OBJECT?

CAR

TIRE

HUBCAP

TRIM

TIRE

HUBCAP

TRIM

TIRE

HUBCAP

TRIM

TIRE

HUBCAP

TRIM

CHASSIS

WHEEL

WHEEL WHEEL

WHEEL

REGISTRATIONNUMBER

SEAT SEAT

SEATSEAT

A Wheel IS-PART-OF a Car

A Car has a COLLECTION of Wheels

Page 31: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object Model

CARREG-NUMBER: STRINGCHASSIS: STRINGWHEELS: SET<WHEEL>SEATS: SET<SEAT>

WHEELTIRE: STRINGHUB CAP: STRINGTRIM: STRING

WHEELTIRE: STRINGHUB CAP: STRINGTRIM: STRING

WHEELTIRE: STRINGHUB CAP: STRINGTRIM: STRING

WHEELTIRE: STRINGHUB CAP: STRINGTRIM: STRING

SEATTIRE: STRINGHUB CAP: STRINGTRIM: STRING

SEATTIRE: STRINGHUB CAP: STRINGTRIM: STRING

SEATTIRE: STRINGHUB CAP: STRINGTRIM: STRING

SEATTYPE: STRINGCOLOUR: STRINGPOSITION: STRING

WHAT IS A COMPLEX OBJECT?

Page 32: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A COLLECTION - SET?

SET - An unordered collection of distinct objects of the same type

e.g, Customers : SET <Customer>;

BILL MARK

HILDA

MARIE

CAROLINE

An instance of CUSTOMERS

Page 33: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A COLLECTION - BAG?

555-9999 444-3333

555-9999

111-3333

444-3333

An instance of PHONE_CALLS

BAG - An unordered collection of objects of the same type

e.g, Phone_calls : BAG <TelephoneNumber>;

Page 34: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A COLLECTION - LIST?

LIST - An ordered collection of objects of the same type

e.g, MachineFaults : LIST <Fault>;

An instance of MachineFaults

Fault at 11:00:01

Fault at 11:00:20

Fault at 11:31:00

Fault at 11:44:33

Fault at 12:00:00

Page 35: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A COLLECTION - ARRAY?

ARRAY – Each object is stored at a particular position

e.g, StudySchedule : ARRAY <Task>;

0 1 2 3 4 5 6 7 8 9 10 11 12 13

TA

SK

#1

TA

SK

#2

TA

SK

#4

TA

SK

#1

TA

SK

#3

TA

SK

#3

TA

SK

#1

An instance of StudySchedule

Page 36: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS A STRUCTURE?

A fixed number of named slots, each of which can contain an object of a particular type.

e.g, CustomersDetails : STRUCTURE < forenames : List < String>, family_name : String, customer_no : Integer >

Marie

Rebecca

CarolineCampbell 9603456

forenames family_name customer_no

An instance of CustomerDetails

Page 37: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS INHERITANCE?

Personnameaddresstelephone_nochange_name (...)change_address (...)

Employeeemployee_nopromote(...)pay_employee (...)

Customercustomer_noplace_order(...)make_payment(...)

TradeCustomertrade_discount%place_order(...)make_payment(...)

IS-AIS-A

IS-A

Page 38: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS MULTIPLE INHERITANCE?

Personnameaddresstelephone_nochange_name (...)change_address (...)

Employeeemployee_nopromote(...)pay_employee (...)

Customercustomer_noplace_order(...)make_payment(...)

Employee_Customerstaff_discount_cardplace_order(...)make_payment(...)

TradeCustomertrade_discount%place_order(...)make_payment(...)

IS-AIS-A

Page 39: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT ARE OBJECT RELATIONSHIPS?

Child ........

Mother ........

* child_of 1

mother_of

one-to-many

Husband ........

Wife ........

1 husband_of 1

wife_of

one-to-one

Child ........

Parent ........

* child_of *

parent_of

many-to-many

Page 40: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT ARE METHODS AND MESSAGES?

GE

T A

GE

ME

TH

OD

B

OD

Y

CH

AN

GE

JOB

ME

TH

OD

B

OD

Y

NAME: MARKDOB: 14/02/64JOB: LECTURER

GET AGE MESSAGE

CHANGE JOB MESSAGE

US

ER

PR

OG

RA

M

OBJECTOBJECT

DISK

Page 41: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS POLYMORPHISM?

CLOCK . . .

SetTime ()SetAlarm ()ShowTime ()

ANALOGUECLOCK

. . .

SetTime ()SetAlarm ()ShowTime ()

DIGITALCLOCK

. . .

SetTime ()SetAlarm ()ShowTime ()

11:00 PM

DIFFERENT TYPES OF OBJECT RESPOND

DIFFERENTLY TO THE SAME MESSAGE

Page 42: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS OVERIDING?

When a sub-class’s method body is used rather than the body of the super-class’s method it is known as overriding.

CUSTOMER

Customer No.

PlaceOrder()MakePayment()

TRADE CUSTOMER

TradeDiscount%

PlaceOrder()

METHOD BODY1. Create order details2. Calculate total cost

METHOD BODY1. Create order details2. Calculate total cost3. Apply Trade Discount

SUP

ER

-CL

ASS

SUB

-CL

AS

S

IS-A

Page 43: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

Object ModelWHAT IS LATE BINDING?

Late or dynamic binding is the ability of the runtime system to determine which method body to execute depending on the type of an object.

CUSTOMERTIRE: STRINGHUB CAP: STRINGTRIM: STRING

Trade CustomerTIRE: STRINGHUB CAP: STRINGTRIM: STRING

CUSTOMERTIRE: HUB CAP: TRIM: STRIN

Trade CustomerCUSTOMER NOPLACE_ORDERMAKE_PAYMENT

Customers := SET <Customer>

FOR x IN CustomersDO x.PLACE_ORDEREND

Where x := an individual Customer Object!

It doesn’t matter if a customer is a trade customer, late binding ensures the appropriate PLACE_ORDER method body is called!

Page 44: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

OODBMS

Page 45: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

OODBMSWHAT IS AN OODBMS?

Object Oriented Database Management Systems (OODBMSs) are an attempt at marrying the power of Object Oriented Programming Languages with the persistence and associated technologies of a DBMS.

OOPLs DBMSs 

Complex Objects PersistenceObject Identity Disc ManagementMethods & Messages Data SharingInheritance ReliabilityPolymorphism SecurityExtensibility Ad Hoc QueryingComputational Completeness

OBJECT ORIENTED DATABASE MANAGEMENT SYSTEM

Page 46: Object-Oriented Database Systems (part 1) CS263 Lecture 17.

OODBMSWHAT AN OODBMS SHOULD SUPPORT?

     Atomic and complex objects     Methods and messages     Object Identity     Single inheritance     Polymorphism - overloading and late-binding     Persistence     Shared Objects 

In addition an OODBMS can optionally support 

     Multiple inheritance     Exception messages     Distribution     Long Transactions     Versions