Object Oriented and Object Relational Models

The object oriented model stores objects with identity, state and behaviour. The object relational model adds those ideas to a relational core, which is the compromise most real products chose.

Concept

Programs are written with objects: things that have identity, hold state and carry behaviour, and that inherit from one another. Relations are flat tables of values. The gap between the two is the impedance mismatch, and these two models are the two attempts to close it.

The object oriented model

The database stores objects directly, using the same concepts as an object oriented language.

ConceptMeaning in the database
ObjectA thing with identity, state and behaviour.
Object identity (OID)A system generated identity independent of any attribute value. Two objects with identical attributes are still different objects.
ClassThe type: which attributes and which methods.
AttributeState, which may itself be an object or a collection.
MethodBehaviour stored with the data.
InheritanceA class extends another and reuses its definition.
EncapsulationState is reached through methods rather than directly.
Complex objectAn object containing other objects or collections, with no flattening required.

Advantages

  • No impedance mismatch — the program structure and the stored structure match.
  • Complex, nested and multimedia data is stored naturally.
  • Behaviour lives with the data.
  • Inheritance is supported directly.

Disadvantages

  • No universally agreed formal foundation comparable to relational theory.
  • Query languages are less standardised, and optimisation is harder.
  • Navigating object references reintroduces something close to pointer chasing.
  • Smaller ecosystem, fewer tools and fewer people who know it.

The object relational model

Rather than replacing relations, this model extends them. The table stays the fundamental structure, and object features are added on top.

ExtensionWhat it allows
User defined typesA column whose type is defined by you, such as an address type with several fields.
Structured typesA single attribute holding several named components.
Collection typesArrays or multisets as attribute values.
Type inheritanceOne defined type extending another.
Methods and routinesBehaviour attached to a type, executed in the database.
ReferencesAn attribute that refers to a row of another table.
Large objectsStoring documents, images and other large values.
   RELATIONAL          OBJECT RELATIONAL        OBJECT ORIENTED

   flat columns        columns may be           objects with
   only                structured, arrays,      identity, methods
                       or user defined types    and inheritance

   strong theory       relational theory kept,  weaker formal
   and optimisation    extensions added         foundation

   most widely used    what most mainstream     niche, specialised
                       products actually are    workloads

Example

-- Illustration only, to show the SHAPE of each model.

-- Purely relational: an address is flattened into columns
customers ( cust_id, name, street, city, pincode )

-- Object relational: an address is a defined type
-- CREATE TYPE address_t AS ( street VARCHAR(80),
--                            city   VARCHAR(40),
--                            pincode CHAR(6) );
customers ( cust_id, name, home_address address_t )

-- Object oriented: an object holding another object,
-- with behaviour attached
-- class Customer { id; name; Address home; billingCity(); }

What happened in practice

Purely object oriented databases found a real but narrow audience — engineering design, scientific and multimedia systems where objects are deeply nested. Mainstream products instead became object relational: they kept relational theory, the optimiser and the tooling, and added types, arrays, large objects, routines and document support.

The impedance mismatch was largely handled a third way: object relational mapping libraries in the application layer, which translate between objects and tables without changing the database model at all.

Common mistakes

  • Confusing the object relational model with object relational mapping. The model is a database capability; the mapping is an application library. Same three words, different things.
  • Saying object oriented databases failed. They did not become mainstream, which is not the same. They are still used where object structures are genuinely deep.
  • Believing object identity is the same as a primary key. A primary key is a value you chose; an OID is generated and independent of every value.
  • Assuming storing a document makes a database object oriented. That is a large object or document type, not object identity, inheritance and behaviour.

Exam and interview questions

  1. What is the impedance mismatch, and which two models try to solve it?
  2. List six concepts of the object oriented data model.
  3. Differentiate object identity from a primary key.
  4. What does the object relational model add to the relational model? Give four extensions.
  5. Why did object relational succeed commercially where purely object oriented did not?

Practice

  1. Model a vehicle hierarchy — vehicle, car, truck — in the relational model, then say what an object relational type inheritance would change.
  2. Give two datasets where a purely object oriented database is genuinely a better fit.
  3. Explain in three sentences why keeping the relational core mattered for optimisation.

Conclusion

The object oriented model stores real objects with identity, inheritance and behaviour. The object relational model keeps relational foundations and adds those features as extensions — the compromise that mainstream products actually adopted.

Useful resources

Hand picked references for this topic
Written by Lorens Mishra

Default administrator account created by the installer.

Continue reading

All DBMS notes →
DBMS

What a Data Model Is

A data model is the set of concepts used to describe data, relationships, semantics and constraints. Models are grouped as high level, representationa...

Read more

Discussion

0 comments
Sign in to join the discussion.

No comments yet. Be the first to say something.