18

Query has not much helped.

As mentioned here, PostgreSQL is ORDBMS.

here, it explains PostgreSQL being RDBMS.


What does it mean that PostgreSQL is an ORDBMS? Is it about supporting user defined datatypes?

overexchange
  • 15,768
  • 30
  • 152
  • 347
  • 3
    Possible duplicate of [Difference between RDBMS and ORDBMS](https://stackoverflow.com/questions/39060110/difference-between-rdbms-and-ordbms) –  Aug 24 '17 at 15:53
  • 1
    @RC. I read that query 100 times. It is just an english literature, helps nothing. That referred query has votes but not the answer. Am sure you got nothing from that query. – overexchange Aug 24 '17 at 16:05
  • Postgres allows to use properites of a JSON object stored in a JSON column within the query. The JSON data columns are a complex data type and are not relational anymore so I would say this is at least one reason why it is not a purely relational database anymore. – t.niese Aug 24 '17 at 16:33
  • @t.niese So, you mean, ORDBMS is about talking around database supporting user defined types? – overexchange Aug 24 '17 at 16:40
  • JSON is not a user defined type it is a type defined by the database. But beeig able to query for data in a json object is not a feature that would match a relational database, because it is a complex data type. It is not about if the type is user defined or not, but about kind of type. – t.niese Aug 24 '17 at 16:59
  • @t.niese yes PostGresSql supports JSON type. How is that related to PostGreSql being ORDBMS? – overexchange Aug 24 '17 at 17:31

1 Answers1

35

An ORDBMS is primarily a relational database that supports some object oriented features.

PostgreSQL or Postgres (not PostGres) supports table inheritance and function overloading. Both are features usually attributed to object oriented languages.

One of the situations where the object-oriented approach is visible is the fact that for each table there is a corresponding data type created. So a table is essentially a set of "instances" of a specific type.

You can even explicitly define a table like that:

create type person_type as (id integer, firstname text, lastname text);
create table person of person_type;

Type inheritance is only supported for table types, not for base types:

create table person (id integer, firstname text, lastname text);
create table person_with_dob
( 
   dob date
) inherits (person);

This is however not fully object oriented because the type definition lacks the ability to defined methods on the type (=class) including method visibility. The closest thing to a type method is a function with that type as the parameter:

create table person (id integer, firstname text, lastname text);

create function fullname(p_row person) returns text
as
$$
  select concat_ws(' ', p_row.firstname, p_row.lastname);
$$ 
language sql;

insert into person (id, firstname, lastname) values (42, 'Arthur', 'Dent');

Now you can run:

select p.fullname
from person p;

and it returns:

fullname   
-----------
Arthur Dent

even though there is no column named fullname in the table person. This behaviour is the closest to a real class/type method found in object oriented languages (but it's not the same thing as it still lacks the ability to define e.g. private methods)


Creating user defined structured data types is typically also seen as an object oriented feature:

create type address_type (city text, zipcode text, street text);

create table person
(
  id integer primary key,
  firstname text,
  lastname text, 
  billing_address address_type, 
  shipping_address address_type
);

Arrays can also be seen as "sets of objects" however this is not necessarily an object oriented feature.

  • 1) If we talk about table Inheritance and function overloading, then, How is OODBMS different from ORDBMS? 2) In relational model, table represents a math relation. If table is considered an object that can be inherited, then does relational model still holds good? – overexchange Aug 24 '17 at 20:27
  • @overexchange: a pure Object Oriented database does not support relational features, mainly it has not query language like SQL –  Aug 24 '17 at 20:33