Abdusebur ADB Assignment
Abdusebur ADB Assignment
Name ……………………………ID
Abdusebur Yusuf-----------0509/16
Submitted to
Mr.BAHER.H
Encapsulation:
Abstraction:
Inheritance:
Example: In a university database, a Person class can be the parent of both Student
and Professor classes, where each inherits basic attributes like name and address.
Polymorphism:
Example: A getProfile() method might work differently for a Student and a Professor,
yet the system can call the method uniformly on any object of type Person.
Definition:
Every object in an OODB is assigned a unique identifier (OID), which distinguishes it
from any other object even if they have identical attributes. This identity persists
regardless of changes in state, allowing consistent references and relationships.
Example:
In an advanced inventory management system, each Product object might have a unique
OID. Even if two products have the same name or specifications, their distinct OIDs
ensure they are tracked correctly in transactions and relationships.
Object Structure
Definition:
An object consists of two main components:
Methods: Define the behaviors or operations that can be performed on the data.
Example:
Consider a BankAccount object in a financial system:
This structure ensures that all operations related to a bank account (like ensuring
sufficient funds before withdrawal) are encapsulated within the object.
Type Constructors
Type constructors are mechanisms that build complex types from simpler ones. They allow
databases to handle more intricate data structures and are essential for modeling relationships
and composite objects.
a. Tuple/Record Constructor
Example: A CustomerOrder record might include fields like orderID, customerID, and
orderDate.
Examples:
Set: A collection where each element is unique. For instance, a TagSet for
articles ensuring no duplicate tags.
c. Dictionary Constructor
Examples:
BankAccount Object:
Encapsulation:
A BankAccount object encapsulates sensitive data like balance and accountNumber
while exposing methods such as deposit(amount), withdraw(amount), and checkBalance().
Direct modification of the balance is avoided by requiring all changes to pass
through these methods, ensuring proper validations (e.g., checking for sufficient
funds).
Persistence:
In a financial application database, once a BankAccount object is created and its
state (current balance, transaction history) is stored, it becomes persistent. This
means that even after the application terminates, the account’s state is saved in the
database, allowing the user to resume operations seamlessly during subsequent
sessions.
Encapsulation:
A Document object may encapsulate attributes like content, author, and status, and
methods such as edit(), approve(), and archive(). This structure keeps the document's
content and its state transitions well-controlled.
Persistence:
Once a document is finalized, its state is persisted in the database so that historical
versions can be accessed, ensuring continuity and traceability in document
management.
Type Hierarchies:
Objects are organized into hierarchies where a general (base) class defines common
attributes and behaviors, and more specialized (derived) classes extend or refine these
definitions.
Inheritance:
Inheritance is the process by which a subclass automatically acquires the attributes and
methods of its superclass, enabling the creation of specialized versions without redundant
code. This mechanism supports polymorphism, allowing a subclass to override or extend
behaviors defined in the superclass.
Examples:
Superclass (Person):
Defines common attributes such as name, dateOfBirth, and contactInformation. It also provides
methods like updateContactInfo().
Subclasses (Student and Professor)
The Student class inherits from Person and adds attributes like studentID,
major, and methods like enrollCourse().
The Professor class also inherits from Person but adds attributes such as
employeeID, department, and methods like assignGrade().
In this type hierarchy, both Student and Professor share common characteristics from Person,
but they also have specialized features that are unique to their roles.
Superclass (Product)
Contains attributes common to all products such as productID, name, price, and description. It
also includes a method updatePrice(newPrice).
Subclasses (Book, Electronics, Clothing):
Each subclass inherits from Product while adding type-specific attributes:
Inheritance ensures that every product has a consistent set of basic attributes and
behaviors, while still accommodating the unique properties required for different product
categories.