Object Relational Database Management System

15
OBJECT RELATIONAL & EXTENDED RELATIONAL DATABASES By Amar Myana

Transcript of Object Relational Database Management System

Page 1: Object Relational Database Management System

OBJECT RELATIONAL & EXTENDED

RELATIONAL DATABASES

By Amar Myana

Page 2: Object Relational Database Management System

THINGS I’LL TALK ABOUT• Relational & Object Oriented Database Management

Systems. AKA( RDBMS & OODBMS )• PostgreSQL ( Object-Relational Database Management

System )• Architecture• Client/Server Model• Storage and Replication• Getting Started

Page 3: Object Relational Database Management System

RDBMS & OODBMS• Born in 1980s• Current Market Share:

RankDBMS Database

Model

ScoreApr

2016Mar

2016Apr2015

Apr2016

Mar2016

Apr2015

1 1 1 Oracle Relational DBMS

1467.53

-4.48 +21.40

2 2 2 MySQL Relational DBMS

1370.11

+22.39

+85.53

3 3 3 Microsoft SQL Server

Relational DBMS

1135.05

-1.45 -14.07

4 4 4 MongoDB Document Store

312.44 +7.11 +33.85

5 5 5 PostgreSQL Relational DBMS

303.73 +4.10 +35.41

75 74 47 Cache Object orientedDBMS

2.19 -0.34 -0.06

Page 4: Object Relational Database Management System

PostgreSQL• Is an Object-Relational Database Management System (ORDBMS)

with an emphasis on extensibility and standard-compliance.• Cross-platform and runs on many operating systems ( *nix, OS X,

Windows )• Features• Implements the majority of the core SQL:2011 standard• ACID Compliant• Transactional avoiding locking issues using multiversion concurrency control (

MVCC )• Immunity to dirty reads and full serializability• Handles complex SQL queries• Updateable views and Materialized Views, triggers, foreign keys; support

functions and stored procedures

Page 5: Object Relational Database Management System

ARCHITECTURE

Page 6: Object Relational Database Management System

Client/Server Model• Types of process:• `postmaster`, supervisory daemon process• Utility processes (bgwriter, walwriter, syslogger, archiver, statscollector

and autovacuum launcher) and• User Backend process (postgres process itself, Server Process)

• Connection Initialization:• Client request for connection to the database, firstly request hit to

postmaster daemon process after performing Authentication and authorization it spawns one new backend server process.• Libpq allows a single frontend to make multiple connections to backend

processes.• Single-threaded process that can only execute one query at a time.

Page 7: Object Relational Database Management System

• Memory• Shared Buffers• WAL Buffers• Clog Buffers• Other Buffers

• PostreSQL shared memory is very big and all the buffers are not in sync, mean all are independent.• Utility Process:

• BG Writer• WAL Writer• Stats-collector• Archiver• Syslogger• WAL Sender• WAL Receiver

Page 8: Object Relational Database Management System

STORAGE AND REPLICATION• Replication• Built-in binary replication & synchronous replcication

• Indexes• Built-in support for regular B-tree and hash indexes, and two types of

inverted indexes• Generalized Search Trees( GiST ), Generalized Inverted Indexes ( GIN )

• Expression indexes, Partial indexes, k-nearest neighbors ( k-NN ) indexing and Block Range Indexes ( BRIN )

• Schemas• A schema holds all objects.• Schemas effectively act like namespaces, allowing objects of the same

name to co-exist in the same database.

Page 9: Object Relational Database Management System
Page 10: Object Relational Database Management System

• User-defined Objects• New types of almost all objets inside the database can be created,

including:• Casts• Conversions• Data types• Domains• Functions, including aggregate functions and window functions• Indexes including custom indexes for custom types• Operators ( existing ones can be overloaded )• Procedural Languages

• Inheritance• Inherit characteristics from a “parent” table.• SELECT * FROM ONLY parent_table;

Page 11: Object Relational Database Management System

Getting Started• To create a new database, in this example named mydb, you use the

following command:• $ createdb mydb

• If you do not want to use your database anymore you can remove it:• $ dropdb mydb

• Accessing a Database• Running the PostgreSQL interactive terminal program, called “psql”, which

allows you to interactively enter, edit, and execute SQL commands.• $psql mydb• psql (version)

Type “help” for help.mydb=>

Page 12: Object Relational Database Management System

• Creating a New Table• CREATE TABLE weather(

city varchar(80), temp_lo int, -- low temperature temp_hi int, -- high temperature prcp real, -- precipitaion date date

);

• DROP TABLE tablename;

• Populating a Table With Rows• INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');• COPY weather FROM '/home/user/weather.txt';

Page 13: Object Relational Database Management System

• Inheritance• It opens up interesting new possibilities of database design.• Let's create two tables: A table cities and a table capitals.• CREATE TABLE cities (

name text,

population real,altitude int -- (in ft)

);

• CREATE TABLE capitals (state char(2)

) INHERITS (cities);

• In this case, a row of capitals inherits all columns (name, population, and altitude) from its parent, cities.

• The following query finds all the cities that are not state capitals and are situated at an altitude of 500 feet or higher:•SELECT name, altitude FROM ONLY cities WHERE altitude > 500;

Page 14: Object Relational Database Management System

Summary• PostgreSQL has many features not touched upon in this

introduction.• PostgreSQL gives much more power for dba and developers

to design the database according to the specific application.• It’s adopted by the major sites like yahoo, reddit etc.• More introductory material, please visit the PostgreSQL

website for links.

Page 15: Object Relational Database Management System

Arigato