Skip site navigation (1) Skip section navigation (2)

Database design advice

From: Neil Saunders <n(dot)j(dot)saunders(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Database design advice
Date: 2005-10-21 15:47:24
Message-ID: ddcd549e0510210847t6a50277fg9160f7993a1a76ca@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi all,

I'm writing a property rental web application, and one of the metrics
I wish to track is the number of page views per month for each
property.

I originally envisaged a table with a column for each month (one row
per property), for which the relevant column would be incremented each
time a property is viewed, depending on the month. But this raises
questions as to the best way to maintain this table (i.e. Create a new
month column each month) I'd prefer to keep all logic in the database,
so would prefer not to use a cron job to do this.

I then thought of using a trigger to check if the relevant column
existed before attempting to increment, but this would only be
utilised once, and then just create overhead at every update in the
future. Should I just create a table with 10 years worth of columns?
Is there a different alternative entirely?

None of the above strike me as architecturally sound, and so any
advice from someone more seasoned in database design would be
gratefully received.

Kind Regards,

Neil.

Responses

pgsql-novice by date

Next:From: Daniel T. StaalDate: 2005-10-21 16:02:16
Subject: Re: Database design advice
Previous:From: Oliver ElphickDate: 2005-10-21 06:48:46
Subject: Re: Array elem as foreign key?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group