[go: up one dir, main page]

0% found this document useful (0 votes)
16 views11 pages

Introduction

Uploaded by

faryalqayyumktk
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)
16 views11 pages

Introduction

Uploaded by

faryalqayyumktk
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/ 11

Advanced data models extend the traditional relational model to handle more complex data,

relationships, and application requirements.

here’s a real-life example that clearly shows why we need advanced data models:

Example: Online Car Selling Platform 🚗

The Traditional Way (Relational Database)

Let’s say you are building a database for a car selling website.

 In a relational model, you’d have tables like:

o Cars → columns: id, brand, model, color, price

o Images → stores car photos separately

o Specifications → stores engine type, horsepower, etc.

 If you need to show a car’s details on the website, you must:

1. Get the car record from Cars.

2. Join with Images to get its photos.

3. Join with Specifications for details.

 It works, but it’s time-consuming and requires a lot of joins.

With Advanced Data Models (Object-Relational or Object-Oriented)

 You can store the car as an object:

o Attributes: brand, model, color, price, engine, horsepower

o Images: stored directly as part of the object

o Methods: calculate_resale_value(), get_fuel_efficiency()

 This way, everything about the car lives together in one place—data + behavior.

 When you fetch a car from the database, you get:

o Its details

o Its pictures

o Its custom functions (like computing discounts)

 No need for multiple joins or scattered data.

Why This Matters

 Faster retrieval – All information about the car comes together.


 Better representation – A car in the database behaves more like a real car in code.

 Easier maintenance – Add a new feature (like 360° car view) without restructuring many
tables.

 Supports complex data – Images, videos, and even 3D models of the car can be stored
directly.

Recap of Basic Data Models

Before we talk about advanced data models, it’s important to understand the basic ones that came
first:

1. Hierarchical Model

o Data is organized like a tree (parent → child relationships).

o Example: A university database where University has Departments, each Department


has Professors, etc.

o Fast for one-to-many relationships, but not flexible for complex queries.

2. Network Model

o Data is stored as records connected by links (like a graph).

o Allows many-to-many relationships.

o Example: Airline reservation system where flights connect to multiple airports and
multiple passengers.

3. Relational Model

o Data stored in tables (rows and columns) with SQL for querying.

o Example: A table Students with columns Name, RollNo, Marks.

o Highly flexible, widely used, but struggles with complex or multimedia data.

1.2 Need for Advanced Models

As technology advanced, new challenges appeared:

 Complex Data → Images, videos, audio, maps, 3D designs.

 Behavior with Data → Need to store not only data, but also how it behaves (methods).

 Bridging OOP & Databases → Most programming is object-oriented, but traditional


databases are table-based.

Problem:
Relational databases require breaking complex data into many tables, which makes storing,
retrieving, and managing them slow and complicated.
Solution:
Advanced data models (like Object-Relational and Object-Oriented) combine object concepts with
databases to handle real-world, complex data more naturally.

Object-Relational Data Models (ORDM) are hybrid database models that combine the strengths of
the relational model (tables, rows, columns, SQL) with features from object-oriented programming
(objects, inheritance, methods).

In simpler terms:
They are relational databases that learned new tricks from OOP so they can handle more complex
and real-world data without losing their compatibility with SQL.

Key Characteristics of ORDM

1. Relational Foundation

 Still stores data in tables (relations) with rows (tuples) and columns (attributes).

 Uses SQL for querying.

 Keeps features like primary keys, foreign keys, and normalization.

2. Object-Oriented Enhancements

 User-Defined Types (UDTs) – You can create custom data types beyond the standard ones.

 Complex Data Types – Support for multimedia (images, videos), spatial data, and arrays.

 Table Inheritance – One table can inherit attributes and behavior from another.

 Methods Associated with Data – Functions can be stored with the data type to operate on
it.

 Encapsulation – Data and the operations that work on it can be packaged together.

Advantages

 Handles complex data like images, audio, GIS data directly.

 Reduces impedance mismatch between object-oriented programming and relational


storage.

 Keeps SQL compatibility while adding flexibility.

 Easier migration from existing relational systems than moving to a pure object-oriented
database.

Limitations

 More complex to design and maintain.

 Can have performance overhead compared to simple relational databases.


 Requires database systems that support OR features.

Examples of ORDM Systems

 PostgreSQL – Rich support for custom data types, table inheritance.

 Oracle Database – Supports object types, nested tables, varrays.

 Informix Universal Server – Designed for multimedia and spatial data.

Simple Real-Life Example

Imagine you run a Property Management System:

 In a traditional relational database, you might have:

o Properties table (address, price, size)

o Images table (property_id, image_file)

o Owners table (owner_id, name, contact)

 In ORDM, you could have:

o A single Property object type that stores address, price, size, images, and methods
like calculate_tax() inside one table row.

 This makes retrieving and managing data faster and more natural.

Entities

In the realm of ORM, entities are synonymous with the objects or classes in object-oriented
programming that are bound to tables in the relational databases. They serve as abstractions of
business objects or the concepts within the application and their definition is in the code. The ORM
component carries out the transformation of these entities into database tables and thus provides
smooth communication between the application and the database that lies underneath that
application.

Relationships

The relationships in ORM map how entities are related to each other, which describes relationships
between tables in a database. These relationships define the way how different elements relate to
each other and these relationships are the essence of data integrity and also serve as a mirror
between various components that are implemented in the application.

Persistence

Persistence refers to the capability to keep data after an application is ended. The use of Object
Relational Mapping (ORM) causes data to persist even when the application is closed or restarted
because it is stored in a relational database that makes it secure and available even when the
application is off. This is the most important function of the ORM because it allows the temporal
persistence of the data used by the application.

CRUD Operations

Crud (Create, Read, Update, Delete) operations constitute the basis of any database interaction. The
use of ORM libraries simplifies the process of the implementation of these operations by
implementing the high-level abstractions. Developers can make changes to entities in their program
and then the ORM allows for translation of these operations into corresponding SQL queries. That
process feeds the need to write complex SQL conditions by developers automatically, creating the
interaction with the database more user-friendly and with less errors.

Query Language

ORM framework is usually a query language designed with object-oriented features for interacting
with the database. For example, Hibernate Package which is a Java-based ORM framework, makes
use of Hibernate Query Language (HQL). HQL allows developers to express database queries by using
object-oriented syntax enabling themselves to get data with ease, manipulating it without directly
dealing with SQL.

Hibernate - Query Language - GeeksforGeeks

Object Oriented Data Models

The Object-Oriented Data Model (OODM) is a database model where data is stored as
objects, just like in object-oriented programming.
These objects contain both the data (attributes) and the operations (methods) that work on
that data.
In other words:
Instead of splitting data into rows and columns like in relational databases, OODM stores it
the way a programmer thinks about it — as real-world objects with properties and
behaviors.

Key Features of OODM


1. Objects
 The basic unit of storage.
 Each object represents a real-world entity.
 Example: A Car object might have:
o Attributes → color, model, engine_size
o Methods → start(), stop(), calculate_mileage()
2. Classes
 Blueprints for creating objects.
 Define what attributes and methods an object will have.
 Example: Class Car → used to create objects like Car1, Car2.
3. Inheritance
 A class can inherit attributes and methods from another class.
 Example:
o Class Vehicle → attributes: make, year
o Class Car inherits from Vehicle and adds number_of_doors.
4. Encapsulation
 Data and methods are bundled together inside the object.
 Prevents outside code from directly changing the data without using the object’s
methods.
5. Polymorphism
 The same method name can work differently depending on the object.
 Example: draw() might work differently for a Circle object vs a Square object.

Advantages
 Natural mapping to real-world entities.
 Better for complex data like multimedia, engineering designs, and scientific models.
 Reusability through inheritance and class design.
 Reduces the gap between programming and database structure (no need to convert
objects into tables).

Limitations
 No universal query standard like SQL (uses OQL or proprietary query languages).
 Steeper learning curve.
 Fewer commercial systems compared to relational databases.

Examples of OODM Systems


 ObjectDB – Pure object database for Java.
 db4o – Embedded object database for Java and .NET.
 Versant Object Database – Enterprise-level object database.

Real-Life Example
Imagine a Hospital Management System:
 In a relational DB, you’d store Patients, Appointments, Doctors in separate tables and
join them when needed.
 In OODM:
o A Patient object might store their name, age, medical history, photos, and
have methods like schedule_appointment() or get_medication_list().
o All related info is stored together, making it easier to retrieve and maintain.

Real-World Use Cases of Object-Oriented Data Models


Object-Oriented Data Models (OODMs) are widely used in industries that require complex
data handling. They are ideal for applications like multimedia databases, healthcare systems,
AI, and geographical information systems, ensuring efficient data management.
Multimedia Databases
Object-Oriented Data Models (OODMs) help store and manage multimedia content
like images, videos, and audio files efficiently. Unlike relational databases, which struggle
with handling such large and complex data types, OODMs allow multimedia files to be
stored as objects with attributes like resolution, format, and duration.
This makes it easier to organize, retrieve, and manipulate multimedia content in applications
like digital libraries, video streaming platforms, and image recognition systems. With
OODMs, multimedia databases can handle high-performance queries while maintaining
data integrity.
Geographical Information Systems (GIS)
Geographical Information Systems (GIS) rely on Object-Oriented Data Models to store and
manage spatial data, such as maps, satellite images, and location coordinates. OODMs allow
GIS applications to represent complex relationships between geographical elements like
roads, buildings, and terrain more naturally.
Each location or geographic feature is treated as an object with attributes like latitude,
longitude, and elevation. This makes it easier to perform spatial analysis, route planning, and
environmental monitoring, improving decision-making in urban planning, transportation,
and disaster management.
Healthcare Systems
Healthcare applications use Object-Oriented Data Models to manage patient records,
medical images, and genetic data. OODMs store each patient as an object, linking their
medical history, prescriptions, and test results within a single unit. This ensures seamless
access to data across different departments, improving diagnosis and treatment planning.
Additionally, complex medical imaging, such as MRIs and CT scans, can be efficiently stored
and retrieved using OODMs. By organizing patient data in an object-oriented way, healthcare
systems enhance data accuracy, security, and accessibility for medical professionals.
Artificial Intelligence (AI) & Machine Learning
OODMs play a crucial role in AI and Machine Learning by storing and managing large
datasets required for training models. AI applications need structured and unstructured
data, such as text, images, and real-time sensor data, which OODMs handle efficiently.
By treating each dataset as an object with attributes like source, format, and category, AI
systems can retrieve and process information quickly. This improves model accuracy,
speeds up training processes, and enables better decision-making in AI-driven applications
like voice recognition, fraud detection, and autonomous vehicles.
Computer-Aided Design (CAD)
Computer-Aided Design (CAD) systems use Object-Oriented Data Models to manage
complex 3D models, blueprints, and design components. Each design element, such as a
machine part or architectural structure, is stored as an object with attributes like
dimensions, material type, and connections to other components.
OODMs make it easier for engineers and designers to modify individual parts without
affecting the entire model. This enhances efficiency in industries like manufacturing,
architecture, and product design, where detailed and scalable designs are essential for
innovation and production.
A Comparison: Object-Oriented vs. Relational Data Models
Data models define how information is structured and managed. Relational models use
tables, while object-oriented models store data as objects. Here’s a comparison of both to
understand their differences and best use cases.
Data Storage & Structure: Tables vs. Objects
Data in relational models is stored in tables with rows and columns, ensuring structure but
requiring joins for relationships. Object-oriented models store data as objects, combining
attributes and behaviors in a single unit. This makes OODMs better suited for complex,
hierarchical data, as objects directly reference each other, improving flexibility and
performance.
Data Relationships: Foreign Keys vs. Object References
Foreign keys link tables in relational models, requiring joins for data retrieval. Object-
oriented models use direct object references, eliminating the need for joins. This simplifies
queries and improves performance, especially in applications with deeply interconnected
data. Object references provide a more intuitive way to manage relationships, making data
access faster and more efficient.
Query Processing: SQL vs. OQL (Object Query Language)
The relational model uses SQL, which relies on joins for retrieving related data, making
queries more complex. The object-oriented model uses OQL, allowing direct retrieval of
objects along with their relationships in a single step. This eliminates joins, simplifying
queries and improving performance, especially for hierarchical or complex data structures.
Performance Considerations: When to Use OODM vs. RDBMS
Structured, transactional applications like banking and ERP systems benefit from relational
models. Object-oriented models handle hierarchical and complex data more efficiently,
making them ideal for AI, IoT, and multimedia. OODMs offer better performance for object-
based datasets, while relational databases remain suitable for applications requiring strict
data integrity and well-defined schemas.

Comparison Table: Relational vs. Object-Oriented Data Models
Object-Oriented Data Model
Feature Relational Data Model (RDBMS)
(OODM)

Data Structure Tables with rows & columns Objects with attributes & methods

Data
Foreign keys & joins Direct object references
Relationships

Query Language SQL (Structured Query Language) OQL (Object Query Language)

Banking, ERP, structured data AI, IoT, multimedia, hierarchical


Best Use Cases
transactions data

Performance Efficient for structured queries Faster for complex data retrieval

More adaptable to complex


Flexibility Fixed schema, less adaptable
relationships

Challenges in Object-Oriented Data Modeling


The challenges in Object-Oriented Data Modeling include high complexity, limited adoption,
and lack of standardization. These factors make implementation difficult and require careful
planning for effective database management.
Higher Complexity
Object-Oriented Data Modeling requires a deep understanding of object-oriented
programming concepts like inheritance, encapsulation, and polymorphism. Designing and
managing objects, their relationships, and behaviors can be challenging. This complexity
increases development effort, making it harder to implement and maintain, especially for
teams unfamiliar with object-oriented approaches.
Limited Adoption
Despite its advantages, Object-Oriented Data Models (OODMs) are not as widely used as
relational models. Most organizations rely on relational databases due to their established
standards, tools, and widespread industry support. As a result, fewer developers and
database administrators specialize in OODMs, limiting their adoption in mainstream
applications.
Lack of Standardization
Unlike relational databases that use SQL, object-oriented databases rely on OQL (Object
Query Language), which lacks universal standardization. Different OODBMS
implementations may have variations in query language and data handling, leading to
compatibility issues. This lack of consistency makes it harder for developers to switch
between different object-oriented database systems.

You might also like