inheritance and audit columns - Mailing list pgsql-novice

From Jules Alberts
Subject inheritance and audit columns
Date
Msg-id 200201141425.g0EEPqLs026069@artemis.cuci.nl
Whole thread Raw
Responses Re: inheritance and audit columns  (Oliver Elphick <olly@lfix.co.uk>)
List pgsql-novice
hi everyone,

i have several questions. first, i want to have audit columns in every
table of my database. these should hold information about who has last
edited a column on which time/date. to avoid a lot of repetition i
would like to use inheritance. something like this:

/** start of code **/
create table audit_cols (
  mut_user varchar(100) not null default current_user,
  mut_timestamp timestamp not null default CURRENT_TIMESTAMP
);

create table foo (
  foo_id serial primary_key,
  foo_name varchar(100)
) inherits (audit_cols);

create table bar (
  bar_id serial primary_key,
  bar_name varchar(100)
) inherits (audit_cols);
/** end of code **/

i have to think of some functions that will automatically fill the
audit_cols columns, but that should not be a big problem, the idea is
that i can have every table inheriting from audit_cols.

what may cause a problem though is that i want to do multiple
inheritance, something like:

/** start of code **/
create table dummy (
  dummy_id serial primary_key,
  dummy_name varchar(100)
) inherits (foo, bar);
/** end of code **/

i have two questions about this statement:

1. the manual says that multiple inheritance is possible, but doesn't
give an example. is the syntax "inherits (foo, bar)" correct?

2. both foo and bar have (inherited) columns called mut_user and
mut_timestamp. can i expect a conflict when creating dummy?

i couldn't find the answers neither in the online help nor in Bruces
book, also online (maybe i didn't search good enough), so TIA for any
pointers!

--
Jules Alberts.

pgsql-novice by date:

Previous
From: Thomas Henningsen
Date:
Subject: Cant find libpq-fe.h
Next
From: Mike Schiraldi
Date:
Subject: initdb not included?