470 likes | 624 Views
Object-Oriented Database Systems (part 1) CS263 Lecture 17. LECTURE PLAN OBJECT DATABASE SYSTEMS PART ONE Advanced database application areas Problems associated with RDBMSs Third Generation DBMSs What is Object Orientation? What is an OODBMS?. DATABASES
E N D
Object-Oriented Database Systems (part 1) CS263 Lecture 17
LECTURE PLAN OBJECT DATABASE SYSTEMS PART ONE • Advanced database application areas • Problems associated with RDBMSs • Third Generation DBMSs • What is Object Orientation? • What is an OODBMS?
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. ADVANCED APPLICATION AREAS
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
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
RELATIONAL DBMSs C# T# S# TRIM SEAT CAR Part of Has Has Part of W# C# C# W# WHEEL Part of Has PROBLEMS - REAL-WORLD OBJECTS ER Diagram - Car
RELATIONAL DBMSs 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…} PROBLEMS - REAL-WORLD OBJECTS NORMALISATION To find out all details about a Car we would have to carry out a large number of (expensive) JOIN operations. Select * From Car, Wheel, Trim, Seat Where Car.C# = Wheel.C# And Car.C# = Seat.C# And Wheel.W# = Trim.W#;
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
RELATIONAL DBMSs D# D# P# P# Oversees Kills We do not record the nature of the relationship between doctor and patient! DOCTOR DOCTOR PATIENT PATIENT Overseen by Killed by D# D# PROBLEMS - SEMANTIC OVERLOADING ER Diagram Doctor{D#, Name, Surgery, etc…} Patient{P#, D#, Name, Address, DOB, etc…}
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
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
RELATIONAL DBMSs PROBLEMS - HOMOGENEOUS DATA STRUCTURE ACCOUNT TABLE BALANCE ACCOUNT CUSTOMER BRANCH 200 JONES STRATFORD 1000.00 324 GRAY BARKING 200.00 345 SMITH STRATFORD 23.17 350 GREEN BARKING 340.14 400 ONO BARKING 500.00 456 KHAN STRATFORD 333.00 ALL ROWS HAVE THE SAME NUMBER OF ATTRIBUTES ALL VALUES IN A COLUMN ARE OF THE SAME TYPE ALL ATTRIBUTE VALUES ARE ATOMIC
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
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
RELATIONAL DBMSs Select E2.ENAME From EMP E1, EMP E2 Where E1.MGR = E2.EMPNO And E1.ENAME = “SMITH”; First Level Answer – SMITH works for FORD ? KING 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 FORD SMITH 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 PROBLEMS - RECURSIVE QUERIES Question - Who does SMITH work for?
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
RELATIONAL DBMSs PROBLEMS - IMPEDANCE MISMATCH SQL is a declarative, set-based language that is not computationally complete! Database applications require the use of a computationally complete, record-based, procedural language such as C, C++, Java, and PL/SQL. We therefore have to map sets of data into records using memory structures such as cursors. This is expensive in terms of application processing time and programming effort, accounting for around 30% of some projects!
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
THIRD GENERATION DBMSs MAIN AIMS • 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.
Object Model 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” 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.
Object Model WHAT IS A (MUTABLE) OBJECT? UNIQUE OBJECT IDENTIFIER (OID) I am an object! ATTRIBUTES NAME MARK DOB 14/02/1964 JOB LECTURER State RELATIONSHIPS BEHAVIOUR CHANGE JOB GET AGE Methods
Object Model WHAT IS A CLASS? I am an object! MARK I am also an object! IAN
Object Model WHAT IS A CLASS? PERSON CLASS MARK IAN So am I! PERSON NAME DOB JOB CHANGE JOB GET AGE I am a Person!
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.
Object Model WHAT IS ENCAPSULATION? GET AGE METHOD GET AGE X CHANGE JOB OBJECT NAME: MARK DOB: 14/02/64 JOB: LECTURER CHANGE JOB METHOD
Object Model WHAT IS A COMPLEX OBJECT? Is a Car a Complex Object? Yes, it’s an object that is made up of other objects! Wheels, Seats, Chassis, Exhaust, Steering Wheel, etc, etc... And… a wheel itself is also a complex object! Tire, Trim, Hub Cap, etc, etc...
Object Model TIRE TIRE TIRE TIRE HUB CAP HUB CAP HUB CAP HUB CAP REGISTRATION NUMBER WHEEL WHEEL TRIM TRIM TRIM TRIM SEAT SEAT WHEEL CHASSIS WHEEL SEAT SEAT WHAT IS A COMPLEX OBJECT? CAR
Object Model TIRE TIRE TIRE TIRE HUB CAP HUB CAP HUB CAP HUB CAP WHEEL WHEEL TRIM TRIM TRIM TRIM WHEEL WHEEL WHAT IS A COMPLEX OBJECT? A Wheel IS-PART-OF a Car REGISTRATION NUMBER SEAT SEAT CAR CHASSIS SEAT SEAT A Car has a COLLECTION of Wheels
Object Model 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? CAR REG-NUMBER: STRING CHASSIS: STRING WHEELS:SET<WHEEL> SEATS: SET<SEAT>
Object Model WHAT IS A COLLECTION - SET? SET - An unordered collection of distinct objects of the same type e.g, Customers : SET <Customer>; MARK BILL An instance of CUSTOMERS HILDA MARIE CAROLINE
Object Model WHAT IS A COLLECTION - BAG? BAG - An unordered collection of objects of the same type e.g, Phone_calls : BAG <TelephoneNumber>; 444-3333 555-9999 An instance of PHONE_CALLS 555-9999 111-3333 444-3333
Object Model WHAT IS A COLLECTION - LIST? LIST - An ordered collection of objects of the same type e.g, MachineFaults : LIST <Fault>; Fault at 11:00:01 Fault at 11:00:20 An instance of MachineFaults Fault at 11:31:00 Fault at 11:44:33 Fault at 12:00:00
Object Model WHAT IS A COLLECTION - ARRAY? ARRAY – Each object is stored at a particular position e.g, StudySchedule : ARRAY <Task>; An instance of StudySchedule TASK #1 TASK #4 TASK #3 TASK #2 TASK #1 TASK #3 TASK #1 0 1 2 3 4 5 6 7 8 9 10 11 12 13
Object Model WHAT IS A STRUCTURE? Marie An instance of CustomerDetails Rebecca 9603456 Campbell Caroline forenames family_name customer_no 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 >
Object Model WHAT IS INHERITANCE? IS-A IS-A IS-A Person name address telephone_no change_name (...) change_address (...) Employee Customer employee_no customer_no promote(...) place_order(...) pay_employee (...) make_payment(...) TradeCustomer trade_discount% place_order(...) make_payment(...)
Object Model WHAT IS MULTIPLE INHERITANCE? IS-A IS-A Person name address telephone_no change_name (...) change_address (...) Employee Customer employee_no customer_no promote(...) place_order(...) pay_employee (...) make_payment(...) Employee_Customer TradeCustomer staff_discount_card trade_discount% place_order(...) place_order(...) make_payment(...) make_payment(...)
Object Model WHAT ARE OBJECT RELATIONSHIPS? Husband Wife .... .... wife_of .... .... one-to-one * child_of 1 mother_of one-to-many Child Parent * child_of * .... .... parent_of .... .... many-to-many 1 husband_of 1 Child Mother .... .... .... ....
Object Model WHAT ARE METHODS AND MESSAGES? OBJECT GET AGE METHOD BODY GET AGE MESSAGE NAME: MARK DOB: 14/02/64 JOB: LECTURER USER PROGRAM CHANGE JOB METHOD BODY CHANGE JOB MESSAGE DISK
Object Model WHAT IS POLYMORPHISM? ANALOGUE CLOCK . . . SetTime () SetAlarm () ShowTime () CLOCK . . . SetTime () SetAlarm () ShowTime () DIGITAL CLOCK . . . SetTime () SetAlarm () ShowTime () 11:00PM DIFFERENT TYPES OF OBJECT RESPOND DIFFERENTLY TO THE SAME MESSAGE
Object Model WHAT IS OVERIDING? CUSTOMER Customer No. PlaceOrder() MakePayment() TRADE CUSTOMER TradeDiscount% PlaceOrder() When a sub-class’s method body is used rather than the body of the super-class’s method it is known as overriding. METHOD BODY 1. Create order details 2. Calculate total cost SUPER-CLASS IS-A METHOD BODY 1. Create order details 2. Calculate total cost 3. Apply Trade Discount SUB-CLASS
Object Model WHAT IS LATE BINDING? Customers := SET <Customer> FOR x IN Customers DO x.PLACE_ORDER END 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 Where x := an individual Customer Object! 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. It doesn’t matter if a customer is a trade customer, late binding ensures the appropriate PLACE_ORDER method body is called!
OODBMS WHAT IS AN OODBMS? OOPLsDBMSs Complex Objects Persistence Object Identity Disc Management Methods & Messages Data Sharing Inheritance Reliability Polymorphism Security Extensibility Ad Hoc Querying Computational Completeness 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. OBJECT ORIENTED DATABASE MANAGEMENT SYSTEM
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 · Long Transactions · Versions