← Back to team overview

dhis2-devs team mailing list archive

Re: Pivot views and resource tables - problem when updating/dropping resource tables referenced by pivot views

 

> Yes but one can theoretically remove and/or change all categories, meaning
> that all columns in the categories resource table will have to be
> re-generated.

Yes, but maybe there are other ways to do this, see below.


> Not saying it can't be done but it is a bit inconvenient. Would it be
> feasible to drop all columns in a table, then add the required columns to
> it? Would the view allow that?

This might be database dependent. If if the DB allowed it, it might
break the view anyway.



> (Just to clarify, we would have those "standard" views in addition to a
> function for adding custom views)

Just what the doctor ordered!

>
> Just curious, in what cases would one not be able to persist views through
> DHIS2 ?

It should not be a problem, as long as DHIS first tested that there
are views that depend on a table being dropped, saved that somehow,
dropped the table and recreated the view. Of course, this operation
could fail depending on the definition of the view. Seems equally
inconvenient.

What about leaving the data model as it is and not dropping the table,
but using an EAV representation of the data instead? SQL/stored
procedures/Java could then be used to pivot the EAV data into a
crosstab view, dynamically. I am thinking back to the SQL I sent a
while back on this (although this was not dynamic and was postgres
specific). Once we know all the possible attributes of a dataset, a
dynamic query could be used to generate the appropriate pivoted data
table.

Not sure I am making sense at this hour. I will think about it some
more and offer up some more blah blah tomorrow. It seems important
though.

Nighty night.



References