Re: Find min year and min value

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
Cc: Steve Crawford <scrawford(at)pinpointresearch(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Find min year and min value
Date: 2007-10-04 12:57:37
Message-ID: A06A0335-C403-423E-8105-3D515CBDC4CC@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Oct 4, 2007, at 6:41 , Stefan Schwarzer wrote:

> So, "value" is something general - it can be (measured in)
> (thousand) Dollars, (Million) People, (Hundred) Hectares etc...

Then I would make a separate table for each variable (as I described
above). For one thing, you're going to have keep track of what units
are associated with which variables are somewhere, whether that be in
your database or possibly your middleware. Separating the variables
into separate tables provides better separation of these value types.

> Queries, as mentioned too, are mainly simple "SELECt * FROM
> specific_variable_like_gdp". But as well on-the-fly aggregations to
> subregions and regions (such as West Africa, and Africa).

If these aggregations are going to be common, you might want to set
up another table that arranges the countries into hierarchies using
nested sets or some other hierarchical strategy (like the adjacency
model or contrib/ltree). I've found nested sets are convenient for
calculating aggregations. You can google or search the archives for
these methods.

> And some calculations which enables to indicate the "completeness"
> of the aggregations (parameters being used are "Number of countries
> included in aggregation in respect to Number of Countries, Total
> Population, Land Area, GDP).

You can use nested sets to handle these calculations as well.

I'm sure there are resources out there that describe database schema
for reporting things such as you describe, as it's not a new problem.
I don't know any off the top of my head, but again, Google is your
friend.

Hope this helps!

Michael Glaesemann
grzm seespotcode net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Miroslav Šulc 2007-10-04 13:35:20 Re: ERROR: variable not found in subplan target lists
Previous Message Andreas Strasser 2007-10-04 12:46:11 Re: Design Question (Time Series Data)