Catalogs

COMP9315 21T1 ♢ Catalogs ♢ [0/11]
❖ Database Objects

RDBMSs manage different kinds of objects

Many objects have names (and, in PostgreSQL, some have OIDs).

How are the different types of objects represented?

How do we go from a name (or OID) to bytes stored on disk?

COMP9315 21T1 ♢ Catalogs ♢ [1/11]
❖ Catalogs

Consider what information the RDBMS needs about relations:

Similarly for other DBMS objects (e.g. views, functions, triggers, ...)

This information is stored in the system catalog tables

Standard for catalogs in SQL:2003: INFORMATION_SCHEMA

COMP9315 21T1 ♢ Catalogs ♢ [2/11]
❖ Catalogs (cont)

The catalog is affected by several types of SQL operations:

where Object is one of table, view, function, trigger, schema, ...

E.g. drop table Groups; produces something like

delete from Tables
where  schema = 'public' and name = 'groups';

COMP9315 21T1 ♢ Catalogs ♢ [3/11]
❖ Catalogs (cont)

In PostgreSQL, the system catalog is available to users via:


The low-level representation is available to sysadmins via:
COMP9315 21T1 ♢ Catalogs ♢ [4/11]
❖ Catalogs (cont)

You can explore the PostgreSQl catalog via psql commands

You can also explore via SQL on the catalog tables
COMP9315 21T1 ♢ Catalogs ♢ [5/11]
❖ Catalogs (cont)

A PostgreSQL installation (cluster) typically has many DBs

Some catalog information is global, e.g.

Other catalog information is local to each database, e.g
COMP9315 21T1 ♢ Catalogs ♢ [6/11]
❖ Catalogs (cont)

Side-note:   PostgreSQL tuples contain

OIDs are used as primary keys in many of the catalog tables.
COMP9315 21T1 ♢ Catalogs ♢ [7/11]
❖ Representing Databases

Above the level of individual DB schemata, we have:

These tables are global to each PostgreSQL cluster.

Keys are names (strings) and must be unique within cluster.

COMP9315 21T1 ♢ Catalogs ♢ [8/11]
❖ Representing Databases (cont)

pg_database contains information about databases:

pg_namespace contains information about schemata: pg_tablespace contains information about tablespaces: PostgreSQL represents access via array of access items:

Role=Privileges/Grantor

where Privileges is a string enumerating privileges, e.g.

jas=arwdRxt/jas,fred=r/jas,joe=rwad/jas

COMP9315 21T1 ♢ Catalogs ♢ [9/11]
❖ Representing Tables

Representing one table needs tuples in several catalog tables.

Due to O-O heritage, base table for tables is called pg_class.

The pg_class table also handles other "table-like" objects:

All tuples in pg_class have an OID, used as primary key.

Some fields from the pg_class table:

COMP9315 21T1 ♢ Catalogs ♢ [10/11]
❖ Representing Tables (cont)

Details of catalog tables representing database tables

pg_class holds core information about tables

pg_attribute contains information about attributes pg_type contains information about types
COMP9315 21T1 ♢ Catalogs ♢ [11/11]


Produced: 15 Feb 2021