❖ Database Objects |
RDBMSs manage different kinds of objects
How are the different types of objects represented?
How do we go from a name (or OID) to bytes stored on disk?
❖ Catalogs |
Consider what information the RDBMS needs about relations:
This information is stored in the system catalog tables
Standard for catalogs in SQL:2003: INFORMATION_SCHEMA
❖ Catalogs (cont) |
The catalog is affected by several types of SQL operations:
createasdropaltergranton
E.g. drop table Groups;
delete from Tables where schema = 'public' and name = 'groups';
❖ Catalogs (cont) |
In PostgreSQL, the system catalog is available to users via:
psql\dinformation_schemaselect * from information_schema.tables;pg_catalogpg_tables❖ Catalogs (cont) |
You can explore the PostgreSQl catalog via psql
\d\d TableTable\df\df+ FunctionFunction\ef FunctionFunction\dv\d+ ViewView❖ Catalogs (cont) |
A PostgreSQL installation (cluster) typically has many DBs
Some catalog information is global, e.g.
PGDATA/pg_global❖ Catalogs (cont) |
Side-note: PostgreSQL tuples contain
create tableoid |
unique identifying number for tuple (optional) | |
tableoid |
which table this tuple belongs to | |
xmin/xmax |
which transaction created/deleted tuple (for MVCC) |
❖ Representing Databases |
Above the level of individual DB schemata, we have:
pg_databasepg_namespacepg_tablespaceKeys are names (strings) and must be unique within cluster.
❖ Representing Databases (cont) |
pg_database
oid, datname, datdba, datacl[], encoding, ...pg_namespaceoid, nspname, nspowner, nspacl[]pg_tablespaceoid, spcname, spcowner, spcacl[]Role=Privileges/Grantor
where Privileges is a string enumerating privileges, e.g.
jas=arwdRxt/jas,fred=r/jas,joe=rwad/jas
❖ 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
CREATE TYPE ASpg_class
Some fields from the pg_class
oid, relname, relnamespace, reltype, relownerrelkind, reltuples, relnatts, relhaspkey, relacl, ...❖ Representing Tables (cont) |
Details of catalog tables representing database tables
pg_class
relname, relnamespace, reltype, relowner, ...relkind, relnatts, relhaspkey, relacl[], ...pg_attributeattrelid, attname, atttypid, attnum, ...pg_typetypname, typnamespace, typowner, typlen, ...typtype, typrelid, typinput, typoutput, ...Produced: 15 Feb 2021