Chapter 11 11 ObjectOriented Databases Database Systems Design
Chapter 11 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4 th Edition Peter Rob & Carlos Coronel
Object Orientation and Its Benefits 4 Object orientation is a modeling and development methodology based on object-oriented (OO) concepts. 11 4 Definition of Object Orientation A set of design and development principles based on conceptually autonomous computer structures known as objects. Each object represents a realworld entity with the ability to interact with itself and with other objects.
11 Table 11. 1 Object Orientation Contributions
The Evolution of OO Concepts 11 4 From traditional to object-oriented programming (OOP) u Before OOP, data and procedures were isolated from each other. Data were treated as the passive component, while procedures manipulated the data as the active component. u Procedural languages (e. g. , COBOL) encouraged the rigid distinction between data and procedure. u In an OOP environment, the programmer asks to perform operations on themselves. u OO concepts first appeared in some programming languages and set the stage for more refined OO concepts.
The Evolution of OO Concepts 11 4 Main Objectives of Object-Oriented Programming Languages (OOPL) u To provide an easy-to-use software development environment. u To provide a powerful software modeling tool for applications prototyping. u To decrease development time by reducing the amount of code. u To improve programmer productivity by making that code reusable.
The Evolution of OO Concepts 4 Important Attributes of OO Environment 11 u The data set is no longer passive. u Data and procedures are bound together, creating an object. u The object has an innate ability to act on itself.
Object-Oriented Concepts 4 Overview 11 u u u Objects: Components and Characteristics Object Identity Attributes (Instance Variables) Object State Messages and Methods Classes Protocol Superclasses, Subclasses, and Inheritance Methods Overriding and Polymorphism Abstract Data Types Object Classification
Object-Oriented Concepts 4 Objects: Components and Characteristics 11 An object is an abstract representation of a real-world entity that has a unique identity, embedded properties, and the ability to interact with other objects and itself. Figure 11. 1 Real World Student Objects
Object-Oriented Concepts 4 Object Identify 11 u The object’s identity is represented by an object ID (OID), which is unique to that object. u The OID is assigned by the system at the moment of the object’s creation and cannot be changed under any circumstance. u The OID can be deleted only if the object is deleted, and that OID can never be reused.
Object-Oriented Concepts 4 Attributes (Instance Variables) 11 u Objects are described by their attributes, known as instance variables. (See Table 11. 2) u Attributes have a domain. The domain logically groups and describes the set of all possible values that an attribute can have. u An attribute can be single valued or multivalued. u Attributes may reference one or more other objects.
Object Attributes 11 Table 11. 2
Object-Oriented Concepts 4 Object State 11 u The object state is the set of values that the object’s attributes have at a given time. l If we change the object’s state, we must change the values of the object attributes. l To change the object’s attribute values, we must send a message to the object. l This message invokes a method.
Object-Oriented Concepts 4 Messages and Methods 11 u Every operation performed on an object must be implemented by a method. l u Methods represent real-world actions and are equivalent to procedures in traditional programming languages. Every method is identified by a name and has a body. l The body is composed of computer instructions written in some programming language to represent a real-world action.
Depiction Of An Object 11 Figure 11. 2
Object-Oriented Concepts 4 Messages and Methods 11 u To invoke a method you send a message to the object. l A message is sent by specifying a receiver object, the name of the method, and any required parameters. l The internal structure of the object cannot be accessed directly by the message sender. The ability to hide the object’s internal details (attributes and methods) is known as encapsulation. l An object may send messages to change or interrogate another object’s state. (See Figure 11. 3)
Objects Send Messages To Each Other 11 Figure 11. 3
Object-Oriented Concepts 4 Classes 11 u Objects that share common characteristics are grouped into classes. A class is a collection of similar objects with shared structure (attributes) and behavior (methods). u Each object in a class is known as a class instance or object instance. (See Figure 11. 4) u Example: STUDENT class (See Figure 11. 5)
Class Illustration 11 Figure 11. 4
Representation Of The Class Student 11 Figure 11. 5
Object-Oriented Concepts 4 Protocol 11 u The class’s collection of messages, each identified by a message name, constitutes the object or class protocol. u The protocol represents an object’s public aspect; i. e. , it is known by other objects as well as end users. u The implementation of the object’s structure and methods constitutes the object’s private aspect. u A message can be sent to an object instance or the class. When the receiver object is a class, the message will invoke a class method.
Public and Private Aspects Of An Object 11 Figure 11. 6
OO Summary: Object Characteristics 11 Figure 11. 7
Object-Oriented Concepts 4 Superclasses, Subclasses, and Inheritance 11 u Classes are organized into a class hierarchy. l Example: Musical instrument class hierarchy (Figure 11. 8) – Piano, Violin, and Guitar are a subclass of Stringed instruments, which is, in turn, a subclass of Musical instruments. – Musical instruments defines the superclass of Stringed instruments, which is, in turn, the superclass of the Piano, Violin, and Guitar classes. u Inheritance is the ability of an object within the hierarchy to inherit the data structure and behavior (methods) of the classes above it.
Musical Instruments Class Hierarchy 11 Figure 11. 8
Object-Oriented Concepts 4 Two variants of inheritance: u 11 Single inheritance exists when a class has only one immediate superclass above it. l Most of the current OO systems support single inheritance. l When the system sends a message to an object instance, the entire hierarchy is searched for the matching method in the following sequence: – Scan the class to which the object belongs. – If the method is not found, scan the superclass. l The scanning process is repeated until either one of the following occurs: – The method is found. – The top of the class hierarchy is reached without finding the message.
Single Inheritance 11 Figure 11. 9
Object-Oriented Concepts 4 Two variants of inheritance: 11 u Multiple inheritance allow a class to be derived from several parent superclasses located above that class. u Single inheritance exists when a class has only one immediate (parent) superclass above it. Figure 11. 10 Multiple Inheritance
Motor Vehicle And Bicycle Instance Variables 11 Figure 11. 11
Object-Oriented Concepts 4 Method Overriding and Polymorphism 11 u We may override a superclass’s method definition by redefining the method at the subclass level. (See Figure 11. 12) u Polymorphism allows different objects to respond to the same message in different ways. (See Figure 11. 13)
Employee Class Hierarchy Method Override 11 Figure 11. 12
Employee Class Hierarchy Polymorphism 11 Figure 11. 13
Object-Oriented Concepts 4 Abstract Data Types 11 u A data type describes a set of objects with similar characteristics. u All conventional programming languages use a set of predefined data types, known as conventional data types or base data types. u Abstract data types (ADT) describe a set of similar objects. An ADT differs from a conventional data type in that: l l The ADT’s operations are user-defined. The ADT does not allow direct access to its internal data representation or method implementation.
Object-Oriented Concepts 4 Object Classification 11 u A simple object contains only single-valued attributes and none of its attributes refer to another object. u A composite object contains at least one multivalued attribute and none of its attributes refer to another object. u A compound object contains at least one attribute that references another object. u A hybrid object contains a repeating group of attributes, and at least one of the repeating attributes refers to another object. u An associative object is used to represent a relationship between two or more objects.
Characteristics of an OO Data Model 4 An Object-Oriented Data Model Must: 11 u Support the representation of complex objects. u Be extensible; i. e. , it must be capable of defining new data types as well as the operations to be performed on them. u Support encapsulation; i. e. , the data representation and the method’s implementation must be hidden from external entities. u Exhibit inheritance; an object must be able to inherit the properties (data and methods) of other objects. u Support the notion of object identity (OID).
Characteristics of an OO Data Model 4 Summary of OODM Components u 11 u u u u The OOCM models real-world entities as objects. Each object is composed of attributes and a set of methods. Each attribute can reference another object or a set of objects. The attributes and the methods implementation are hidden, or encapsulated, from other objects. Each object is identified by a unique object ID (OID), which is independent of the value of its attributes. Similar objects are described and grouped in a class that contains the description of the data and the method’s implementation. The class describes a type of object. Classes are organized in a class hierarchy. Each object of a class inherits all properties of its superclasses in the class hierarchy.
Comparing The OO And E-R Model Components 11 Table 11. 3
- Slides: 36