2 Object And Object Relational Databases

Advanced Database ยท Unit 2 ยท 10 hrs

Object and Object Relational Databases

Exam-focused notes for Object and Object Relational Databases (Advanced Database, CSC475): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.

Object and Object Relational Databases in short

This unit covers object databases and the object-relational model: how object-oriented ideas were incorporated into database systems and into SQL itself, the ODMG standard and its object definition and query languages, and how object-relational engines handle nested and semi-structured data today.

Object and Object Relational Databases: notes

Object Database Concepts

An object-oriented database (OODB) represents data as objects and classes, exactly as object-oriented programming does: an object is a real-world entity with its own identity, and a class is a collection of objects sharing structure and behaviour. An OODB combines object-oriented programming with database persistence, aiming to model real-world concepts more directly than flat tables can. Its defining characteristics are a direct correspondence between real-world and database objects, a system-generated object identifier (OID) independent of any attribute value, extensibility to new user-defined data types and operations, encapsulation of an object's data behind its methods, inheritance between classes, and overloading, overriding and late binding of methods. Advantages include richer modeling of real-world entities, native support for complex data types (images, audio, video), support for long-duration transactions, and a more expressive query language than plain SQL. The drawbacks are equally real: there is no single, universally agreed object data model (unlike the relational model), the systems are harder for inexperienced users, standardization and security support are weaker, and implementations tend to be complex.

What this unit covers

  • Object Database Concepts
  • Object Database Extensions to SQL
  • The ODMG Object Model and the Object Definition Language ODL
  • Object Database Conceptual Design
  • Object Query Language OQL
  • Language Binding in the ODMG Standard

Object Database Concepts

2081 ยท 10 marks

Explain different object database concepts in brief. What are type constructors?[10]

Show solved answer

Object Database Concepts and Type Constructors

Part 1: Object Database Concepts

Object databases (also called Object-Oriented Databases) combine the advantages of object-oriented technologies with traditional database systems. The main goal is to improve the modeling of real-world concepts in the database.

Key Object Database Concepts


1. Object Identity

Every object in an object database has a unique, system-generated identifier called an Object Identifier (OID). Unlike relational databases where identity is based on key values, OIDs are independent of the object's attribute values and remain stable even if the data changes.


2. Complex Objects

Object databases support complex (composite) objects that can contain other objects as attributes. This allows modeling of real-world entities more naturally. For example, an Employee object can contain an Address object as an attribute.


3. Encapsulation

Object databases support encapsulation, which means that both data (attributes) and behavior (methods/operations) are bundled together within an object. External users interact with objects only through defined interfaces. This is provided through the mechanism of user-defined types.


4. Classes and Type Hierarchy

Objects are grouped into classes based on shared attributes and methods. Classes can be organized into a type hierarchy using inheritance, allowing subclasses to inherit properties and methods from superclasses. In SQL-based object databases, this is supported using the keyword UNDER.


5. Inheritance

Inheritance allows a new class (subclass) to derive properties and behaviors from an existing class (superclass). This promotes reusability and reduces redundancy. For example:

Person (superclass)
  โ””โ”€โ”€ Employee UNDER Person (subclass)
  โ””โ”€โ”€ Student UNDER Person (subclass)

6. Object References

Objects can reference other objects using reference types. This replaces the concept of foreign keys in relational databases and allows direct navigation between related objects.


7. Polymorphism

The same operation can behave differently on different types of objects. This allows flexible and extensible database design.


8. Object Query Language (OQL)

Object databases are queried using OQL (Object Query Language), which is an SQL-like declarative language. It provides:

  • High-level primitives for object sets and structures
  • Support for object identity and complex objects
  • Syntax similar to SQL but extended with object-oriented features

9. Persistence

Objects in an object database are persistent, meaning they continue to exist beyond the execution of the program that created them, unlike transient objects in memory.


Part 2: Type Constructors

Type constructors are mechanisms used in object-relational and object databases to define complex or structured data types beyond the basic primitive types (integer, string, etc.).

Definition

A type constructor is a mechanism that allows the creation of new, complex data types by combining or structuring existing types.


Two Main Categories of Type Constructors

1. Row Type (Tuple / Struct) Constructor

  • Used to create a structured type that groups multiple attributes together, similar to a record or struct.
  • Allows a single attribute to hold multiple sub-attributes.
  • Example:
CREATE TYPE Address AS (
    street   VARCHAR(50),
    city     VARCHAR(30),
    zipcode  CHAR(10)
) NOT FINAL;

Here, Address is a row type that groups street, city, and zipcode into a single structured type.


2. Collection Type Constructor

Collection types allow an attribute to hold multiple values of the same type. There are three main collection type constructors:

ConstructorDescription
SetAn unordered collection of unique elements (no duplicates)
ListAn ordered collection of elements (duplicates allowed)
Bag (Multiset)An unordered collection where duplicates are allowed

Example:

-- A SET of phone numbers for an employee
CREATE TYPE PhoneSet AS SET(VARCHAR(15));

-- Using it in a table
CREATE TABLE Employee (
    emp_id    INT,
    name      VARCHAR(50),
    phones    PhoneSet
);

FeatureDescription
Reference TypeSpecifies object identifiers to allow one object to reference another
EncapsulationOperations are encapsulated within user-defined types
Inheritance (UNDER)New types can be derived from existing types using the UNDER keyword

Summary Table

ConceptDescription
Object IdentityUnique OID for every object
EncapsulationData + behavior bundled together
InheritanceSubclass inherits from superclass using UNDER
Complex ObjectsObjects containing other objects
OQLSQL-like language for querying objects
Row Type ConstructorGroups multiple attributes into one structured type
Collection Type ConstructorSet, List, Bag for multi-valued attributes
Reference TypeMechanism for object-to-object references

Conclusion

Object database concepts extend traditional relational databases by incorporating object-oriented principles such as identity, encapsulation, inheritance, and complex types. Type constructors, specifically row type (tuple/struct) and collection type (set, list, bag) constructors, are fundamental tools that enable the definition of rich, complex data structures needed to model real-world entities accurately.

Open this answer on its own page โ†’

2079 ยท 10 marks

What are different concepts and features of object oriented databases? What is object relational model?[10]

--- Object Oriented Databases (OODB) combine the advantages of object-oriented programming (OOP) with traditional relational databases. The fundamental idea is: Object-Oriented Programming + Relational Database Features = Object-Oriented Database Model The main goal of OODB is to combine the adva...

Open this answer on its own page โ†’

The ODMG Object Model and the Object Definition Language ODL

2081 ยท 5 marks

Explain ODMG object model. [5]

ODMG stands for Object Data Management Group. It is a standard data model upon which the Object Definition Language (ODL) and Object Query Language (OQL) are based. It is designed to provide a standard data model for object-oriented databases, combining features of object-oriented programming wit...

Open this answer on its own page โ†’

2080 ยท 5 marks

What is ODMG object model? What is object definition language? [5]

Show solved answer

ODMG Object Model and Object Definition Language


ODMG Object Model

ODMG stands for Object Data Management Group. It is a standard data model upon which the Object Definition Language (ODL) and Object Query Language (OQL) are based. It is meant to provide a standard data model for object databases.

Main Parts of ODMG

The ODMG standard is made up of the following parts:

PartDescription
Object ModelCore data model for object databases
Object Definition Language (ODL)Language to define object schemas
Object Query Language (OQL)SQL-like language to query objects
Language BindingsBindings to OOP languages (C++, Java, etc.)

Key Concepts in the ODMG Object Model

The ODMG object model differentiates between Objects and Literals:

Objects:

  • Have both an Object Identifier (OID) and a state (current data)
  • Values can be modified
  • May be transient or persistent

Literals:

  • Have a value (state) but no Object Identifier
  • Have a constant value
  • May be atomic, structure, or collection

Advantages of ODMG-based Object Databases

  • Speed: Data can be accessed faster because an object can be retrieved directly
  • Improved performance: Best suited for object-oriented programming
  • Extensibility: Any kind of data structure can be used to hold data
  • Avoids impedance mismatch between the database and the programming language

Object Definition Language (ODL)

Object Definition Language (ODL) is a language used in the context of object-oriented databases to define the structure and characteristics of objects within a database. In ODL, data is organized and stored as objects rather than in traditional relational tables.

Common Elements of ODL

ElementDescription
ClassesDefine the blueprint/template for objects
AttributesProperties or data fields of a class
RelationshipsAssociations between classes/objects
InheritanceAllows a class to derive properties from a parent class
MethodsBehaviors or operations defined on objects
ConstraintsRules that enforce data integrity

Summary

ODL provides a powerful and expressive language for defining object-oriented database schemas. It enables the modeling and organization of data in a way that closely aligns with object-oriented programming concepts, making it natural to use alongside languages like C++ and Java through their respective ODMG language bindings.

Open this answer on its own page โ†’

2079 ยท 5 marks

Define ODMG Object model? What is Object Query Language(OQL)? [5]

--- ODMG stands for Object Data Management Group. It is a standard data model designed to provide a common foundation for object-oriented databases. The ODMG object model is the standard upon which Object Definition Language (ODL) and Object Query Language (OQL) are based. It is meant to provide ...

Open this answer on its own page โ†’

Object Database Extensions to SQL

2080 ยท 10 marks

Compare object oriented database with object relational database. What are different object database features that have been included in SQL?[10]

--- Feature Object Oriented Database (OODB) Object Relational Database (ORDB) --------- Base Model Purely based on object oriented programming principles Combines features of both OOP and relational database (RDBMS) Data Storage Data is stored as objects directly Data is organized in relational t...

Open this answer on its own page โ†’