The Object–oriented Data Model (OODM) represents data as objects, mirroring the structure used in Object-Oriented Programming (OOP). Each object encapsulates both state (data attributes, like a person’s name) and behavior (methods or functions that operate on the data, like calculating age). Objects are grouped into classes, which act as blueprints defining the attributes and methods for all objects of a type. A key feature is inheritance, allowing a new class (subclass) to automatically acquire attributes and methods from an existing class (superclass), promoting code reuse. Furthermore, objects can maintain complex relationships, including associations, aggregation, and composition. This model integrates seamlessly with OOP languages, eliminating the “impedance mismatch” of relational systems, and is adept at representing complex, interconnected real-world entities with rich behavior directly within the database.
Components of Object-oriented Data Models:
- Objects and Object Identity (OID)
An Object is the fundamental unit, representing a real-world entity. Unlike a relational tuple, an object is a capsule containing both state (data attributes/instance variables) and behavior (methods/functions that operate on that data). Each object is assigned a unique, system-generated Object Identifier (OID) that is independent of its attribute values. This OID is a permanent, immutable pointer, ensuring the object’s unique identity even if its state changes. This contrasts with the relational model, where uniqueness is defined by the value of a primary key attribute.
- Classes and Class Hierarchy
A Class is a blueprint or template that defines the structure (attributes) and behavior (methods) for a set of similar objects. Individual objects are instances of a class. The model organizes classes into a Class Hierarchy through inheritance. A Subclass (or derived class) can inherit attributes and methods from a Superclass (or base class). This promotes code reusability and allows for the natural modeling of “is-a” relationships (e.g., an Employee is-a Person). A subclass can also add new attributes and methods or override inherited ones to specialize its behavior.
- Inheritance
Inheritance is the mechanism that allows a subclass to acquire the properties and methods of its superclass. It is a primary feature for achieving extensibility and reusability in the model. There are different types, such as single inheritance (one superclass) and multiple inheritance (multiple superclasses). Inheritance enables polymorphism, where a method defined in a superclass can be invoked on subclass objects, but the specific implementation that executes is determined by the object’s actual class at runtime. This allows for writing more general and flexible code.
- Encapsulation
Encapsulation is the bundling of an object’s data (attributes) and the methods that manipulate that data into a single, self-contained unit. The internal state of an object is typically not directly accessible from outside the object; it can only be accessed or modified through a public interface of defined methods. This principle of information hiding protects the object’s integrity by preventing external code from putting the data into an invalid state. It decouples the external interface from the internal implementation, making the system more modular, maintainable, and secure.
- Polymorphism
Polymorphism (from Greek for “many forms”) allows operations or methods to behave differently based on the actual type of object they are applied to. In practice, this means that a single method name, defined in a superclass, can be implemented differently in various subclasses. For example, a draw() method would have different implementations for Circle and Square subclasses of a Shape superclass. The database or application can invoke draw() on any Shape object, and the correct version will be executed automatically, making the system highly flexible and extensible.
Uses of Object-oriented Data Models:
One thought on “Object-oriented Data Models, Components, Uses, Limitations, Example”