Presentation is loading. Please wait.

Presentation is loading. Please wait.

OBJECT DATABASE SYSTEMS PART ONE  Advanced database application areas  Problems associated with RDBMSs  Third Generation DBMSs  What is Object Orientation?

Similar presentations


Presentation on theme: "OBJECT DATABASE SYSTEMS PART ONE  Advanced database application areas  Problems associated with RDBMSs  Third Generation DBMSs  What is Object Orientation?"— Presentation transcript:

1 OBJECT DATABASE SYSTEMS PART ONE  Advanced database application areas  Problems associated with RDBMSs  Third Generation DBMSs  What is Object Orientation?  What is an OODBMS?

2 ADVANCED APPLICATION AREAS DATABASES  Computer-Aided Design (CAD).  Computer-Aided Manufacturing (CAM).  Computer-Aided Software Engineering (CASE).  Multimedia Systems.  Digital Publishing.  Geographic Information Systems (GIS).  Scientific and Medical Systems.

3 RELATIONAL DBMSs  Poor representation of ‘real world’ entities.  Semantic overloading.  Homogeneous data structure.  Difficulty handling recursive queries.  Impedance mismatch. PROBLEMS

4 RELATIONAL DBMSs PROBLEMS - REAL-WORLD OBJECTS CAR C# WHEEL W# SEAT S# TRIM T# C# W# C# Has Part of Has Part of Has ER Diagram - Car

5 RELATIONAL DBMSs PROBLEMS - REAL-WORLD OBJECTS Select * From Car, Wheel, Trim, Seat Where 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

6 RELATIONAL DBMSs PROBLEMS - SEMANTIC OVERLOADING ER 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!

7 RELATIONAL DBMSs PROBLEMS - HOMOGENEOUS DATA STRUCTURE 333.00STRATFORDKHAN456 500.00BARKINGONO400 340.14BARKINGGREEN350 23.17STRATFORDSMITH345 200.00BARKINGGRAY324 1000.00STRATFORDJONES200 BALANCE BRANCHCUSTOMERACCOUNT ACCOUNT TABLE ALL ROWS HAVE THE SAME NUMBER OF ATTRIBUTES ALL VALUES IN A COLUMN ARE OF THE SAME TYPE ALL ATTRIBUTE VALUES ARE ATOMIC

8 RELATIONAL DBMSs PROBLEMS - RECURSIVE QUERIES Question - Who does SMITH work for? SMITH Select E2.ENAME From EMP E1, EMP E2 Where E1.MGR = E2.EMPNO And E1.ENAME = “SMITH”; First Level Answer – SMITH works for FORD FORD JONES Select E3.ENAME From EMP E1, EMP E2, EMP E3 Where 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 E4 Where 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 ?

9 RELATIONAL DBMSs PROBLEMS - 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.

10 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 DBMSs MAIN AIMS

11 Object Model WHAT 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 False Char - e.g. a, b, c, @, #, !, etc... String - e.g. “Mark”, “Database Systems”

12 Object Model WHAT IS A (MUTABLE) OBJECT? I am an object! UNIQUE OBJECT IDENTIFIER (OID) NAMEMARK DOB14/02/1964 JOBLECTURER ATTRIBUTES State RELATIONSHIPS CHANGE JOB GET AGE BEHAVIOUR Methods

13 Object Model WHAT IS A CLASS? I am an object! MARK I am also an object! IAN

14 Object Model WHAT IS A CLASS? MARK I am a Person! So am I! IAN PERSON CLASS PERSON NAME DOB JOB CHANGE JOB GET AGE

15 Object Model WHAT 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.

16 Object Model WHAT IS ENCAPSULATION? GET AGE METHOD CHANGE JOB METHOD NAME:MARK DOB:14/02/64 JOB:LECTURER GET AGE CHANGE JOB OBJECT

17 Object Model WHAT 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...

18 Object Model WHAT IS A COMPLEX OBJECT? CAR TIRE HUB CAP TRIM TIRE HUB CAP TRIM TIRE HUB CAP TRIM TIRE HUB CAP TRIM CHASSIS WHEEL SEAT REGISTRATION NUMBER

19 Object Model WHAT IS A COMPLEX OBJECT? CAR TIRE HUB CAP TRIM TIRE HUB CAP TRIM TIRE HUB CAP TRIM TIRE HUB CAP TRIM CHASSIS WHEEL REGISTRATION NUMBER SEAT A Wheel IS-PART-OF a Car A Car has a COLLECTION of Wheels

20 Object Model CAR REG-NUMBER:STRING CHASSIS:STRING WHEELS:SET SEATS:SET WHEEL TIRE: STRING HUB CAP: STRING TRIM: STRING WHEEL TIRE: STRING HUB CAP: STRING TRIM: STRING WHEEL TIRE: STRING HUB CAP: STRING TRIM: STRING WHEEL TIRE: STRING HUB CAP: STRING TRIM: STRING SEAT TIRE: STRING HUB CAP: STRING TRIM: STRING SEAT TIRE: STRING HUB CAP: STRING TRIM: STRING SEAT TIRE: STRING HUB CAP: STRING TRIM: STRING SEAT TYPE: STRING COLOUR: STRING POSITION: STRING WHAT IS A COMPLEX OBJECT?

21 Object Model WHAT IS A COLLECTION - SET? SET - An unordered collection of distinct objects of the same type e.g, Customers : SET ; BILL MARK HILDA MARIE CAROLINE An instance of CUSTOMERS

22 Object Model WHAT 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 ;

23 Object Model WHAT IS A COLLECTION - LIST? LIST - An ordered collection of objects of the same type e.g, MachineFaults : LIST ; 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

24 Object Model WHAT IS A COLLECTION - ARRAY? ARRAY – Each object is stored at a particular position e.g, StudySchedule : ARRAY ; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 TASK #1 TASK #2 TASK #4 TASK #1 TASK #3 TASK #1 An instance of StudySchedule

25 Object Model WHAT 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, family_name : String, customer_no : Integer > Marie Rebecca Caroline Campbell 9603456 forenames family_name customer_no An instance of CustomerDetails

26 Object Model WHAT IS INHERITANCE? Person name address telephone_no change_name (...) change_address (...) Employee employee_no promote(...) pay_employee (...) Customer customer_no place_order(...) make_payment(...) TradeCustomer trade_discount% place_order(...) make_payment(...) IS-A

27 Object Model WHAT IS MULTIPLE INHERITANCE? Person name address telephone_no change_name (...) change_address (...) Employee employee_no promote(...) pay_employee (...) Customer customer_no place_order(...) make_payment(...) Employee_Customer staff_discount_card place_order(...) make_payment(...) TradeCustomer trade_discount% place_order(...) make_payment(...) IS-A

28 Object Model WHAT 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

29 Object Model WHAT ARE METHODS AND MESSAGES? GET AGE METHOD BODY CHANGE JOB METHOD BODY NAME:MARK DOB:14/02/64 JOB:LECTURER GET AGE MESSAGE CHANGE JOB MESSAGE USER PROGRAM OBJECT DISK

30 Object Model WHAT IS POLYMORPHISM? CLOCK... SetTime () SetAlarm () ShowTime () ANALOGUE CLOCK... SetTime () SetAlarm () ShowTime () DIGITAL CLOCK... SetTime () SetAlarm () ShowTime () 11:00 PM DIFFERENT TYPES OF OBJECT RESPOND DIFFERENTLY TO THE SAME MESSAGE

31 Object Model WHAT 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 BODY 1. Create order details 2. Calculate total cost METHOD BODY 1. Create order details 2. Calculate total cost 3. Apply Trade Discount SUPER-CLASS SUB-CLASS IS-A

32 Object Model WHAT 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. CUSTOMER TIRE: STRING HUB CAP: STRING TRIM: STRING Trade Customer TIRE: STRING HUB CAP: STRING TRIM: STRING CUSTOMER TIRE: HUB CAP: TRIM: STRIN Trade Customer CUSTOMER NO PLACE_ORDER MAKE_PAYMENT Customers := SET FOR x IN Customers DO x.PLACE_ORDER END 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!

33 OODBMS WHAT 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. OOPLsDBMSs Complex ObjectsPersistence Object IdentityDisc Management Methods & MessagesData Sharing InheritanceReliability PolymorphismSecurity ExtensibilityAd Hoc Querying Computational Completeness OBJECT ORIENTED DATABASE MANAGEMENT SYSTEM

34 OODBMS WHAT 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  Versioning

35 LECTURE PLAN OBJECT DATABASE SYSTEMS PART TWO  What is an OODBMS?  Advantages and Disadvantages of OODBMSs  What is an ORDBMS?  What is SQL3?  Comparison of OODBMSs and ORDBMSs  When to use an OODBMS  When to use an ORDBMS

36 REQUIREMENTS AND FEATURES OODBMSs Requirements: Transparently add persistence to OO programming languages Ability to handle complex data - i.e., Multimedia data Ability to handle data complexity - i.e., Interrelated data items Add DBMS Features to OO programming languages Features: The host programming language is also the DML. The in-memory and storage models are merged. No conversion code between models and languages is needed.

37 TWO-LEVEL STORAGE MODEL FOR A RDBMS SQL Transforming and type checking Main or virtual memory Secondary storage

38 Record 3. Access object 4. Copy modified fields 2. Copy relevant fields 5. Save page 1. Read page Page Application memory DBMS Cache Secondary Storage ACCESSING A RECORD USING AN RDBMS

39 Main or virtual memory Secondary storage SINGLE-LEVEL STORAGE MODEL FOR AN OODBMS

40 3. Access object 5. Save page 1. Read page Page Application memory Secondary Storage Object 4. Swizzle pointers back, etc. 2. Swizzle pointers, etc. ACCESSING AN OBJECT USING AN OODBMS

41 ADVANTAGES OODBMSs  Enriched modelling capabilities  Extensibility  Removal of Impedance Mismatch  Support for schema evolution.  Applicable for advanced database applications  Improved performance.

42 DISADVANTAGES OODBMSs  Lack of a universal data model  Lack of experience  Lack of standards.  Ad-hoc querying compromises encapsulation.  Locking at object-level impacts performance  Complexity  Lack of support for views  Lack of support for security

43 WHAT IS AN ORDBMS? In essence ORDBMSs are an attempt to add OO to Tables! ORDBMSs Definition: Object-Relational databases extend the Relational Data Model to address those weaknesses identified previously. An Object-Relational database adds features associated with object-oriented systems to the Relational Data Model.

44 MAJOR DIFFERENCE BETWEEN AN ORDBMS AND AN OODBMS OODBMSs try to add DBMS functionality to one or more OO programming languages. ORDBMSs REVOLUTIONARY IN THAT THEY ABANDON SQL ORDBMSs try to add richer data types and OO features to a relational DBMS. EVOLUTIONARY IN THAT THEY EXTEND SQL

45 WHAT IS SQL3? ORDBMSs SQL3 or SQL/99: SQL3 is a superset of SQL/92, in that it supports all of the constructs supported by that standard, as well as adding new ones of its own. Therefore, whatever worked in an implementation of SQL/92 should also work in an implementation of SQL3. HOWEVER, IT SHOULD BE NOTED THAT AS YET THERE ARE NO IMPLEMENTATIONS OF SQL3!

46 WHAT IS NEW IN SQL3? ORDBMSs  Extended Base Types.  Row Types.  User-Defined Types.  User-Defined Routines.  Sub-Types and Super-Types.  Sub-Tables and Super-Tables.  Reference Types and Object Identity.  Collection Types.

47 SQL3 - EXTENDED BASE TYPES ORDBMSs ONE OF THE REASONS FOR THE MOVE AWAY FROM RDBMSs IS THE LIMITED BASE TYPE AVAILABILITY: BASE TYPES AVAILABLE IN SQL/92 INCLUDE: NUMBER, CHAR, DATE,... BASE TYPES IN SQL3 ARE EXTENSIBLE. THEREFORE THE FOLLOWING MUCH NEEDED TYPES COULD BE ADDED (PROVIDED SOMEBODY CREATES THEM!) VIDEO, IMAGE, AUDIO, TEXT, SPATIAL, TEMPORAL, GEOGRAPHIC, WEB-PAGES,...

48 SQL3 - ROW TYPES ORDBMSs CITY AREASTREET ADDRESS OXFORDMARSDENHIGH ST.30 LONDONLEYTONHIGH RD.20 LONDONBARKINGMAIN ST.10 BRANCHNO CREATE TABLE branch ( branchno VARCHAR(3), address ROW ( street VARCHAR(25), area VARCHAR(15), city VARCHAR(15)); COLUMN ATTRIBUTES NO LONGER HAVE TO BE ATOMIC!

49 SQL3 - USER-DEFINED TYPES ORDBMSs CREATE TYPE person_type AS ( PRIVATE date_of_birth DATE CHECK (date_of_birth > DATE ‘1900-01-1901’), PUBLIC nameVARCHAR(15) NOT NULL, addressVARCHAR(50) NOT NULL, tel_noVARCHAR(13) NOT NULL, FUNCTION get_age (P person_type) RETURNS INTEGER /* code to calculate age from date_of_birth */ RETURN END) NOT FINAL; An example of a User-Defined Routine (UDR)

50 SQL3 - SUB-TYPES & SUPER-TYPES ORDBMSs PERSON-TYPE date of birth name address tel-no get_age() STAFF-TYPE sno position salary branch is_manager() Sub-Types and Super-Types are used to allow for INHERITANCE in SQL3 A Sub-Type can inherit from more than one Super-Type. Multiple Inheritance is allowed!

51 SQL3 - SUB-TYPES & SUPER-TYPES ORDBMSs Another example of a User-Defined Routine (UDR) CREATE TYPE staff_type UNDER person_type AS ( snoVARCHAR(5) NOT NULL UNIQUE, positionVARCHAR(10) NOT NULL, salaryNUMBER(7,2), bnoVARCHAR(3) NOT NULL, CREATE FUNCTION is_manager (s STAFF_TYPE) RETURNS BOOLEAN BEGIN IF s.position = ‘Manager’ THEN RETURN TRUE; ELSE RETURN FALSE; END IF END) NOT FINAL;

52 SQL3 - TYPES & TABLES ORDBMSs In order to remain upwardly compatible with SQL-92, TYPES can ONLY be instantiated through SQL Tables! Therefore, in order to create instances of a type we first have to create a table to store those instances in! CREATE TABLE staff OF STAFF_TYPE ( PRIMARY KEYsno); EXAMPLE: In order to create staff instances we first have to do one of the following: CREATE TABLE staff ( infoSTAFF_TYPE, PRIMARY KEYsno);

53 SQL3 - SUB-TABLES & SUPER-TABLES ORDBMSs PROBLEM - What happens if we create two or more tables for the same TYPE? How do we find all TYPE instances? CREATE TABLE lecturer OF STAFF_TYPE ( PRIMARY KEYsno); EXAMPLE: FIND ALL MEMBERS OF STAFF! CREATE TABLE admin OF STAFF_TYPE ( PRIMARY KEYsno); The only way of doing this is to declare the lecturer and admin tables as sub-tables of a staff super-table!

54 SQL3 - SUB-TABLES & SUPER-TABLES ORDBMSs CREATE TABLE lecturer OF STAFF_TYPE UNDER staff ( PRIMARY KEYsno); CREATE TABLE admin OF STAFF_TYPE UNDER staff ( PRIMARY KEYsno); CREATE TABLE staff OF STAFF_TYPE ( PRIMARY KEYsno); SUPER-TABLE SUB-TABLES SOLUTION TO PROBLEM (FIND ALL STAFF): SQL> SELECT * FROM staff;

55 SQL3 - REFERENCE TYPES AND OIDS ORDBMSs A Reference Type is the SQL3 equivalent of an OID in an OODBMS. Reference Types allow a row to be shared among multiple tables, and enable users to replace complex join operations with path expressions! CREATE TYPE staff_type UNDER person_type AS ( snoVARCHAR(5) NOT NULL UNIQUE, positionVARCHAR(10) NOT NULL, salaryNUMBER(7,2), next_of_kin REF(person_type) bnoVARCHAR(3) NOT NULL) NOT FINAL; CREATE TABLE person OF person_type ( oidREF(person_type) VALUES ARE SYSTEM GENERATED); EXAMPLE: Could point to a row in ANY table containing a person_type!

56 SQL3 - REFERENCE TYPES AND OIDS ORDBMSs To ensure that a REFERENCE is limited to a single table, a SCOPE has to be added to the table using the REFERENCE! CREATE TYPE staff_type UNDER person_type AS ( snoVARCHAR(5) NOT NULL UNIQUE, positionVARCHAR(10) NOT NULL, salaryNUMBER(7,2), next_of_kin REF(person_type) bnoVARCHAR(3) NOT NULL) NOT FINAL; CREATE TABLE person OF person_type ( oidREF(person_type) VALUES ARE SYSTEM GENERATED); EXAMPLE: CREATE TABLE staff OF staff_type ( PRIMARY KEY sno, SCOPE FOR next_of_kin IS person); staff next_of_kin will point to a row in the person table!)

57 SQL3 - COLLECTION TYPES ORDBMSs List (base) - ordered collection allows duplicates Array (base) - one-dimensional array, max no. Set (base) - unordered collection, no duplicates Multiset(base) - unordered collection, allows duplicates SQL3 COLLECTION TYPES ARE THE EQUIVALENT OF COLLECTION TYPES IN OODBMSs KNOWN AS A ‘BAG’ IN AN OODBMS!

58 SQL3 - COLLECTION TYPES ORDBMSs CREATE TABLE branch ( bnoNUMBER(3), addressROW ( streetVARCHAR(15), areaVARCHAR(15), cityVARCHAR(15) staffSET (STAFF_TYPE)); EXAMPLE THE USE OF COLLECTION TYPES WITHIN TABLES ENSURE THAT TABLES NO LONGER HAVE TO BE IN 1NF REPEATING GROUPS ARE ALLOWED!

59 SQL3 - OTHER ADDITIONS ORDBMSs THE MAIN ADDITIONS TO SQL THAT ARE NOT SPECIFICALLY ASSOCIATED WITH ADDING OBJECT-SUPPORT ARE THE FOLLOWING: SQL IS NOW COMPUTATIONALLY COMPLETE PERSISTENT STORED MODULES ARE SUPPORTED TRIGGERS ARE SUPPORTED

60 OODBMS or ORDBMS CONSIDERATIONS OODBMS - put more emphasis on the role of the client, i.e., Client side caching! This can radically improve long, process intensive, transactions. ORDBMS - SQL is still the language for data definition, manipulation and query – Still have Impedance Mismatch! OODBMSs have been optimised to directly support object- oriented applications and specific OO languages. ORDBMSs are supported by most of the ‘major players’ in the DBMS market place.

61 OODBMS or ORDBMS CONSIDERATIONS ORDBMS - Most third-party database tools are written for the relational model (SQL-92), and will therefore be backward-compatible with SQL3. ORDBMS - search, access and manipulate complex data types in the database with standard SQL (SQL3), without breaking the rules of the relational data model. OODBMS – The ODMG standard group’s OQL is now the de-facto query language amongst OODBMS vendors. However, in order to use it, collection objects (known as extents) have to first be created for each class.

62 OODBMS or ORDBMS CONSIDERATIONS OODBMS - In order to realise the value of an OODBMS you must build your application using methods written in one of several object-oriented language (i.e. C++, Java, Smalltalk).

63 WHEN TO USE AN OODBMS OODBMS or ORDBMS In applications that generally retrieve relatively few (generally physically large) highly complex objects and work on them for fairly long periods of time. This will necessitate the use of client caching, pointer swizzling, and non-locking forms of concurrency control.

64 WHEN TO USE AN ORDBMS OODBMS or ORDBMS In applications that process a large number of short- lived (generally ad-hoc query) transactions on data items that can be arbitrarily complex in structure. Where the main emphasises is on efficient query optimisation to limit disk accesses, and traditional concurrency control is acceptable.


Download ppt "OBJECT DATABASE SYSTEMS PART ONE  Advanced database application areas  Problems associated with RDBMSs  Third Generation DBMSs  What is Object Orientation?"

Similar presentations


Ads by Google