composition v. inheritance - Mailing list pgsql-novice

From Tom Strickland
Subject composition v. inheritance
Date
Msg-id 20010618100122.G1439@lyra.stricklandc.demon.co.uk
Whole thread Raw
Responses Re: composition v. inheritance  (Tom Strickland <tom@stricklandc.demon.co.uk>)
List pgsql-novice
For our CRM database, we have a table called 'action', which defines
'time spent by an employee doing something'. The intent is to extend
this table to encompass specific actions, such as time spent training
groups of clients, correspondance on behalf of a client... The trouble
is that simple inheritance probably won't work because of a need for
multiple inheritence. I am toying with the idea of composition, with
another table 'action_composite':

CREATE TABLE action_composite(
action_id INTEGER,
table_ref VARCHAR(20),
CONSTRAINT a_compos_pkey PRIMARY KEY(action_id, table_ref)
);

ALTER TABLE action_composite ADD CONSTRAINT action_id_fk
FOREIGN KEY(action_id) REFERENCES action(action_id) ON UPDATE CASCADE;

I'm not sure about table_ref, but it would either be a reference to
the table's id or a VARCHAR containing the table's name. In this way a
an action in the real world that consists of 'work on a client's
problem' and 'correspondance' can be represented. I am uneasy about
this solution - it feels slightly wrong. Can anyone help?

Thanks,

Tom

pgsql-novice by date:

Previous
From: Yeo Eng Hee
Date:
Subject: OpenSSL problems
Next
From: Tom Strickland
Date:
Subject: Re: composition v. inheritance