0% found this document useful (0 votes)
5 views6 pages

Abdusebur ADB Assignment

Uploaded by

yabdusabur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Abdusebur ADB Assignment

Uploaded by

yabdusabur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

HARAMAYA UNIVERSITY

COLLEGE OF COMPUTING AND


INFORMATICS
DEPARTMENT OF COMPUTER
SCIENCE

Name ……………………………ID
Abdusebur Yusuf-----------0509/16

Submitted to
Mr.BAHER.H

Submission date march


31-2025
Chapter 1: Concepts for Object-Oriented
Databases
1. Overview of Object-Oriented Concepts
Object-oriented databases (OODBs) are designed to bring the principles of object-oriented
programming (OOP) into data management. Instead of solely relying on tables and rows like in
relational databases, OODBs encapsulate both data and behavior in the form of objects. This
model naturally represents complex relationships and real-world entities.

 Encapsulation:

Definition: Bundling data (attributes) and methods (operations) together.

Example: A multimedia object in a streaming service not only stores attributes


such as title and release date but also includes methods to play, pause, or rate the
media.

 Abstraction:

Definition: Hiding complex implementation details while exposing only essential


features.

Example: A Customer object in an e-commerce database might expose methods


for purchasing and order tracking, while the internal logic for payment processing
remains hidden.

 Inheritance:

Definition: Allowing objects to inherit properties and behaviors from a parent


(superclass) so that common functionalities can be reused.

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:

Definition: The ability to treat objects of different classes through a common


interface, often through method overriding.

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.

Why O-O Concepts Matter in Databases?


1. Natural Modeling: The object model aligns closely with how we perceive real-
world entities, making it easier to design and maintain complex systems.
2. Modularity and Reusability: Encapsulation and inheritance promote the development of
modular systems where components can be reused or extended without rewriting core
functionality.
3. Complex Data Relationships: Object identity and structured types allow advanced databases
to handle intricate relationships and nested data structures more intuitively than traditional
relational models.

2. Object Identity, Object Structure, and Type Constructors


Object Identity

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:

Attributes: Represent the data or state of the object.

Methods: Define the behaviors or operations that can be performed on the data.

Example:
Consider a BankAccount object in a financial system:

Attributes: accountNumber, balance, accountHolderName

Methods: deposit(amount), withdraw(amount), checkBalance()

 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

Purpose: To create a composite type with named fields.

Example: A CustomerOrder record might include fields like orderID, customerID, and
orderDate.

b. Collection Constructors (Set, List, Array)

Purpose: To create collections of objects.

Examples:

Set: A collection where each element is unique. For instance, a TagSet for
articles ensuring no duplicate tags.

List/Array: An ordered collection of elements. A Playlist in a music


streaming database is typically an ordered list of Song objects.

c. Dictionary Constructor

Purpose: To create mappings of key-value pairs.

Example: A UserPreferences object might use a dictionary to map preference


categories (keys) to specific settings or values.

3. Encapsulation of Operations, Methods, and Persistence


Encapsulation is the mechanism of bundling an object’s data (its attributes) together with the
operations (methods) that manipulate that data. This principle not only simplifies interaction with
the object but also safeguards the internal state by restricting direct access.

 Data and Behavior Integration:


An object encapsulates both its state and the functions that modify it. This design means that
users interact with objects via their public methods rather than directly manipulating internal
data.
 Data Hiding:
Encapsulation hides the internal implementation details. Only a well-defined interface is
exposed, reducing the risk of unintended interference and misuse of data.
 Operations/Methods:
Methods are the procedures or functions defined within a class that perform operations on
the object’s data. They ensure that any changes to an object's state occur in a controlled
manner.
 Persistence:
In the context of object-oriented databases, persistence refers to the ability of objects to
maintain their state across sessions. A persistent object is stored in the database so that even
after the application stops, the object's data can be retrieved and reused later.

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.

Document Management System:

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.

4. Type Hierarchies and Inheritance


Type hierarchies and inheritance allow object-oriented databases to organize objects in a
structured manner, promoting code reuse and logical data modeling.

 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:

University Database Example:

 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.

E-Commerce System Example:

 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:

A Book might include author and ISBN.

An Electronics item might have warrantyPeriod and brand.

Clothing might add size and material.

 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.

You might also like