Re: To get a Table or View like a Calendar with dates

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Csanyi Pal" <csanyipal(at)gmail(dot)com>,<pgsql-novice(at)postgresql(dot)org>
Subject: Re: To get a Table or View like a Calendar with dates
Date: 2012-08-15 21:08:38
Message-ID: 502BC9860200002500049768@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Csanyi Pal <csanyipal(at)gmail(dot)com> wrote:

> The first table contains the ordinal number of the semester (1 or
> 2) and the start dates of the same:
>
> iskolanaptar_201213=# select * from felevek_kezdetei_1_8;
> felev1v2 | datum
> ----------+------------
> 1 | 2012-09-03
> 2 | 2013-01-15
> (2 rows)
>
> The second table contains the end date of the first semester and
> the number of the days in this semester:
>
> iskolanaptar_201213=# select * from felev1_vege_tan_nap_1_8;
> datum | ennyi_tan_nap
> ------------+---------------
> 2012-12-21 | 78
> (1 row)

I think you need to rethink the table structure. It's not
immediately obvious why you wouldn't include the date of the end of
the semester in the same table as the start date for the semester
and the semester identifying information. You might want to read up
on data normalization for relational databases. The usual way of
organizing something like semester information would be to have a
table with the columns which identify a semester (perhaps school
year and semester number) and all the data elements which require
both of those elements, and only those elements, to determine the
correct value. That would probably include start date and end date
for the semester. (Or if you can start development with 9.2 beta at
this point, it might be even better to use a date range instead of
the two dates.)

You'll be in much better shape if you organize your data that way.
If you review the literature, you want to shoot for "3rd normal
form" -- below that level things tend to be pretty messy; above that
can get pretty esoteric.

-Kevin

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Raymond McKolay 2012-08-17 17:45:05 Vacuum error message
Previous Message Csanyi Pal 2012-08-15 20:07:46 Re: To get a Table or View like a Calendar with dates