Re: casts for user defined types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mary Anderson <maryfran(at)demog(dot)berkeley(dot)edu>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: casts for user defined types
Date: 2007-08-07 19:06:04
Message-ID: 27262.1186513564@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Mary Anderson <maryfran(at)demog(dot)berkeley(dot)edu> writes:
> I am using inheritance of types in the following way on a ROLAP
> schema to allow for extra dimensions to be used:

> CREATE TABLE data (data_id int4 SERIAL,
> data_value double,
> ... some dimensions);
> CREATE TABLE extra_dimensions (xdimension varchar[],
> xvalue varchar[])
> INHERITS FROM data;

> Suppose I do
> INSERT INTO data (data_value) VALUES 1.1;

> This gives me a row in the data table, but not in the extra_dimensions
> table. What do I do if I want to define an extra dimension for this row
> at a later date? It seems I should be able to do a CAST of some kind.

You would have to delete the row from the parent table and insert the
same data (plus the added stuff) into the child table.

I think you should reconsider this schema. extra_dimensions is not
really buying you anything: just put those columns in the main table
and allow them to default to NULL when not needed.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Demian Quinonez 2007-08-08 22:17:44 restoring with sql script
Previous Message Mary Anderson 2007-08-07 18:50:13 casts for user defined types